Login
Register

VirtueMart

WooCommerce

Others

Docs

Support

Blog

About

Shipping by Rules for VirtueMart

IMPORTANT ANNOUNCEMENT: Plugin development ceased, all plugins made available freely (GPL)

With great sadness we have to announce that we are ceasing development of all our VirtueMart, WooCommerce and Joomla plugins. Effective immediately, all our plugins -- even those that were paid downloads -- are made available for free from our homepage (GPL license still applies), but we cannot and will not provide any support anymore.

It has been a great pleasure to be part of the thriving development communities of VirtueMart as well as WooCommerce. However, during the last year it became painstakingly clear that in addition to a full-time job, a young family and several other time-consuming hobbies at professional level (like being a professional singer) the plugin development and the support that it requires is not sustainable and is taking its toll. It has been an honor, but it is now time to say good bye!

×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Using width to set the price 23 May 2017 06:34 #1

  • gareth
  • gareth's Avatar Topic Author
Hi,

I am trying to use the Width to set certain prices. Basically, if the item width 24 then the cost is $24.00
I am using this:

Name= Shipping to Nationwide; TotalWidth=="8"; Shipping=8
Name= Shipping to Nationwide; TotalWidth=="14"; Shipping=14
Name= Shipping to Nationwide; TotalWidth=="19"; Shipping=19
Name= Shipping to Nationwide; TotalWidth=="24"; Shipping=24

this is for smaller items.

But it doesnt work. Basically it loads no rate. No error, just no cost.


Iam also using this code as a shipping formular which I use for large Items. this works well

Name= Shipping to Kaitaia; State=="Kaitaia"; Shipping=Weight*182
Name= Shipping to Kawakawa; State=="Kawakawa"; Shipping=Weight*115
Name= Shipping to Kawerau; State=="Kawerau"; Shipping=Weight*132
Name= Shipping to Kerikeri; State=="Kerikeri"; Shipping=Weight*185
Name= Shipping to Kumeu; State=="Kumeu"; Shipping=Weight*76
Name= Shipping to Levin; State=="Levin"; Shipping=Weight*145
Name= Shipping to Masterton; State=="Masterton"; Shipping=Weight*166
Name= Shipping to MtMaunganui; State=="Mt Maunganui"; Shipping=Weight*99
Name= Shipping to Napier; State=="Napier"; Shipping=Weight*132
Name= Shipping to Nelson; State=="Nelson"; Shipping=Weight*380
Name= Shipping to NewPlymouth; State=="New Plymouth"; Shipping=Weight*123
Name= Shipping to Oamaru; State=="Oamaru"; Shipping=Weight*400
Name= Shipping to Orewa; State=="Orewa"; Shipping=Weight*95
Name= Shipping to Palmerston North; State=="Palmerston North"; Shipping=Weight*139
Name= Shipping to Queenstown; State=="Queenstown"; Shipping=Weight*586
Name= Shipping to Rangiora; State=="Rangiora"; Shipping=Weight*440
Name= Shipping to Rotorua; State=="Rotorua"; Shipping=Weight*98
Name= Shipping to Russell; State=="Russell"; Shipping=Weight*142
Name= Shipping to Silverdale; State=="Silverdale"; Shipping=Weight*80
Name= Shipping to Taumaranui; State=="Taumaranui"; Shipping=Weight*185
Name= Shipping to Taupo; State=="Taupo"; Shipping=Weight*140
Name= Shipping to Tauranga; State=="Tauranga"; Shipping=Weight*98
Name= Shipping to Thames; State=="Thames"; Shipping=Weight*109
Name= Shipping to Timaru; State=="Timaru"; Shipping=Weight*369
Name= Shipping to Tokoroa; State=="Tokoroa"; Shipping=Weight*109
Name= Shipping to Wanaka; State=="Wanaka"; Shipping=Weight*586
Name= Shipping to Wanganui; State=="Whanganui"; Shipping=Weight*166
Name= Shipping to Warkworth; State=="Warkworth"; Shipping=Weight*80
Name= Shipping to Washdyke; State=="Washdyke"; Shipping=Weight*339
Name= Shipping to Wellington; State=="Wellington"; Shipping=Weight*199
Name= Shipping to Wellsford; State=="Wellsford"; Shipping=Weight*79
Name= Shipping to Westport; State=="Westport"; Shipping=Weight*390
Name= Shipping to Whakatane; State=="Whakatane"; Shipping=Weight*142
Name= Shipping to Whangarei; State=="Whangarei"; Shipping=Weight*109
Name= Shipping to Nationwide; TotalWidth=="8"; Shipping=8
Name= Shipping to Nationwide; TotalWidth=="14"; Shipping=14
Name= Shipping to Nationwide; TotalWidth=="19"; Shipping=19

What am I doing wrong?

Thanks!

Using width to set the price 25 May 2017 17:43 #2

Dear Gareth,
A few points:
- the with is a number, while "8" is technically a string, so TotalWidth=="8" can never be true, as the left side is a number and the right side a string. The proper condition should be TotalWidth==8.
- Do I understand you correctly that you want to calculate shipping costs depending on the width of each individual product and then sum up the costs of each product? Unfortunately, this is not possible with our plugin. Our plugin works at the cart level and does not do calculations for each product separately. The TotalWidth variable that you are using is the SUM of all widths of all products in the cart.

Please let me know if I'm misunderstanding anything. If you can describe your shipping cost structure in detail, we can try to figure out whether and how it might still be implemented in our plugin.

Best regards,
Reinhold

Using width to set the price 01 Jun 2017 00:18 #3

  • gareth
  • gareth's Avatar Topic Author
Ah I see, Thanks.

Ok, I will try to explain and hopefully the map I have created will help.

In New Zealand there are 2 island. And because some of the items I sell are large (Pool Tables) it makes better sense for me to have 2 ware houses to try and keep the shipping costs down for customers

Warehouse 1 ships the large Items to the north island

Warehouse 2 ships the large items to the south island

I use the formular: Name= Shipping to Gisborne; State=="Gisborne"; Shipping=Weight*182
Under pool table product weight I use "1". This way it charges $ 182 to ship to Gisborne from the North Island Warehouse
And I can do this for both the North and The south

All of the Smaller items ship from the North Island. So these can be sold to anyone in the south and the North Island. These are sent my courier as opposed to trucks.
So I need a formula to apply to the smaller items. I could put the wieght in as 0.3 which would work for the North Island ok with the current pool table formular. But if I use this and ship to the South Island the shipping would not be enough becuase they are coming from all the way form the north Island
Hopefully that makes sense. Perhaps you can suggest a better way to do this.

Thanks
Attachments:

Using width to set the price 01 Jun 2017 00:20 #4

  • gareth
  • gareth's Avatar Topic Author
Just had a thought would it be better to set 2 different zones. North And South. If so what formulas would be best?

Using width to set the price 04 Jun 2017 18:16 #5

Dear Gareth,
Thank you for your explanation about the two islands and the large items being shipped from a coresponding warehouse on each of the islands, while the small items are always sent from the northern island warehouse.

So, how do you actually calculate your shipping costs? Let's take an example:

Customer 1 (south island) buys two Pool Tables and five smaller items.
If I understood your posting correctly, you charge $182 to ship one talbe, so the two tables will be $384. How much do you charge to ship the smaller Items to the southern island? You say that they will be shipped by courier, so I suppose the shipping costs for the smaller items will be completely independent from the shipping costs of the pool tables? Do I understand your initial post correctly that you want to have different shipping costs per item, and that you achieve this by "abusing" the width variable to hold the shipping costs you want for each particular product?

If so, I would recommend using different categories (can even be unpublished categories, so the display in the shop will not be influenced) to distinguish the larger items from the smaller ones. Let's say you charge $182 to ship a pool table (depending on the destination state!) and for the small items you simply want to use the width variable (which holds the shipping costs), independent of the destination state. In the following example, the category that indicates large items has ID 1234.
Variable=NrPoolTables; Value=evaluate_for_categories(Articles, 1234)
Variable=ShippingSmallItems; Value=TotalWidth - evaluate_for_categories(TotalWidth, 1234)

Name= Shipping to Kaitaia; State=="Kaitaia"; Shipping=NrPoolTables*182 + ShippingSmallItems
Name= Shipping to Kawakawa; State=="Kawakawa"; Shipping=Weight*115 + ShippingSmallItems
Name= Shipping to Kawerau; State=="Kawerau"; Shipping=Weight*132 + ShippingSmallItems
Name= Shipping to Kerikeri; State=="Kerikeri"; Shipping=Weight*185 + ShippingSmallItems
Name= Shipping to Kumeu; State=="Kumeu"; Shipping=Weight*76 + ShippingSmallItems
Name= Shipping to Levin; State=="Levin"; Shipping=Weight*145 + ShippingSmallItems
[...]

Let me explain these rules in a bit more detail:
Basically, you need
* the number of pool tables (i.e. the number of articles from category 1234), and
* the sum of all widths of all products NOT in category 1234. This can be calculated the sum of all articles (TotalWidth) minus the sum of all articles from category 1234

These two items are calculated in the first two lines, stored in custom variables (NrPoolTables and ShippignSmallItems) and will be used in all subsequent rules.
The following rules implement the different shipping costs for one pool table, depending on the destination state (it's always NrPoolTables * [individual pool table shipping cost for each destination state]), PLUS the nationwide shipping costs for the small items (which are already calculated an stored in the variable ShippingSmallItems).

For this to work, you need to assign all large items to a custom category (the category with ID 1234 in our example => you need to replace the 1234 with the ID of your actual category).

Best regards,
Reinhold

Using width to set the price 07 Jun 2017 03:00 #6

  • gareth
  • gareth's Avatar Topic Author
Thanks for detailed explaination. Much appreciated.

Ok thanks, So if I was to set up to Categories Nrlarge and Sthlarge. I could us the code:

Variable=Nrlarge; Value=evaluate_for_categories(Articles, 1234)
Variable=Sthlarge; Value=evaluate_for_categories(Articles, 5678)

I have child products for each LARGE item:
North island
South Island

See here: nuff.co.nz/shop/viper-8-pool-tableNew%20Zealand

This allows me to keep track of stock in the separate warehouses
so I could put these in the Categories aswell as the category of pool table or air hockey or whatever it may be. If I unpublished the “nrlarge” category will it still work?


Then for the smaller Items it may be best do this properly as opposed to a “Hack”

Could I do


Variable=Nrlarge; Value=evaluate_for_categories(Articles, 1234)
Variable=Sthlarge; Value=evaluate_for_categories(Articles, 5678)

Name=North Island Courier; Variable=Nrsmall; Value=evaluate_for_categories(Articles, abcd)
Name=South Island Courier; Variable=Sthsmall; Value=evaluate_for_categories(Articles, efgh)


Name= Shipping to Kaitaia; State=="Kaitaia"; Shipping=NrPoolTables*182 + Shipping=Nrsmall*10 + shipping=Stsmall*20

Hopefully you can see what I am trying to acheive :)

Using width to set the price 15 Jun 2017 04:41 #7

  • gareth
  • gareth's Avatar Topic Author
Hi Any Chance of getting a response. Would love to try and get this going. Im just waiting on this to get the site live. :)

Using width to set the price 18 Jun 2017 23:57 #8

Dear Gareth,
Using unpublished categories for all kinds of stuff is actually the recommended way in VirtueMart. using evaluage_for_categories will still work if you unpublish the Nrlarge and Sthlarge categories.

Regarding your small items: You initially said that the small items are always shipped from the north-island warehouse, so the shipping cost should only depend on the destination, not on the category, right? If I understand your approach now, you have some small items (category abcd) shipped from the north island warehouse and some small items shipped from the south island warehouse? If so, your approach makes perfect sense and is exactly how I would approach the problem.

Anyway, your approach for the shipping rule is almost correct: You don't need to (actually you MUST not) repeat the "shipping=". So your rule should be
Name= Shipping to Kaitaia; State=="Kaitaia"; Shipping=NrPoolTables*182 + Nrsmall*10 + Stsmall*20

Please note that your approach depends on all products having one of the categories with ID 1234, 5678, abcd or efgh assigned! If you forget to assign to a product one of these categories, it will simply be ignored in the shipping costs. That's why I usually use a remainder variable, e.g.
Name=North Island Courier; Variable=Nrsmall; Value=Articles - evaluate_for_categories(Articles, 1234, 5678, efgh)
instead of "Value=evaluate_for_categories(Articles, abcd)". If you forgot to add to a product one of the categories, it will simply count as a small product shipped from the north island warehouse.

Best regards,
Reinhold

Using width to set the price 19 Jun 2017 02:37 #9

  • gareth
  • gareth's Avatar Topic Author
HI Thanks,

But all small items are shipped from the North Island and the cost will be dependent on the distance it will go.
and the size of the weight of the small item. So this can just be "Courier"

I have set up categories
Nlarge
Slarge
Courier

I have put the child product of the pool table which is for the North island warehouse in the category of "Nlarge"

And then used :

Name= Shipping to Kaitaia; State=="Kaitaia"; Shipping=Nlarge*182 + Courier*10


But I get the error:
Evaluation yields unknown value while evaluating rule part 'Nlarge'.

I think I am missing something?

Using width to set the price 19 Jun 2017 02:47 #10

  • gareth
  • gareth's Avatar Topic Author
Also use the rule:
Variable=Nlarge; Value=evaluate_for_categories(Articles, 23)

Using width to set the price 19 Jun 2017 02:55 #11

  • gareth
  • gareth's Avatar Topic Author
Is there a way I can just pay you to do this for me:) Do you offer anything like this?

Regards

Gareth

Using width to set the price 20 Jun 2017 04:48 #12

  • gareth
  • gareth's Avatar Topic Author
Ok so I am there with the Large Items But the small (Courier) items I cant get it work.
I would it so that it will work out the courier Item if it is by itself or it will add it to the large item if a large item is present.
Each city I can add a new rate for the courier

Something like:
Name= Shipping to Auckland; State=="Auckland"; Shipping=Nlarge*weight*65 + Courier*weight*10

Thinking the weight x 10 is the price to ship to Auckland. The weight will be set at "1" in the product so the cost will be $10.
When I do this with the pool table the shipping is 65 which is correct, but when I add a pool cue"Courier" item the shipping goes to 150. See attached. If the pool cue is by itself the shipping is $10. Its only when they are combined.




Can you help with this last bit please. Im going bald :)

This is what I have so far.....



Variable=Nlarge; Value=evaluate_for_categories(Articles, 23)
Variable=Slarge; Value=evaluate_for_categories(Articles, 25)
Variable=Courier; Value=evaluate_for_categories(Articles, 28)

North Isalnd
Name= Shipping to Auckland; State=="Auckland"; Shipping=Nlarge*weight*65 + Courier*weight*10


Name= Shipping to Auckland - Silverdale; State=="Auckland - Silverdale"; Shipping=Nlarge*weight*85
Name= Shipping to Auckland - Warkworth; State=="Auckland - Warkworth"; Shipping=Nlarge*weight*85
Name= Shipping to Auckland - Whangaparoa; State=="Auckland - Whangaparoa"; Shipping=Nlarge*weight*85
Name= Shipping to Auckland - Kumeu; State=="Auckland - Kumeu"; Shipping=Nlarge*weight*87
Name= Shipping to Dargaville; State=="Dargaville"; Shipping=Weight*185
Name= Shipping to Edgecumbe; State=="Edgecumbe"; Shipping=Weight*132
Name= Shipping to Gisborne; State=="Gisborne"; Shipping=Nlarge*weight*185
Name= Shipping to Hamilton; State=="Hamilton"; Shipping=Nlarge*weight*92
Name= Shipping to Hastings; State=="Hastings"; Shipping=Nlarge*weight*165
Name= Shipping to Havelock North; State=="Havelock North"; Shipping=Nlarge*weight*169
Name= Shipping to Hawea; State=="Hawea"; Shipping=Nlarge*weight*520
Name= Shipping to Kaikohe; State=="Kaikohe"; Shipping=Nlarge*weight*169
Name= Shipping to Kaitaia; State=="Kaitaia"; Shipping=Nlarge*weight*185
Name= Shipping to Kawakawa; State=="Kawakawa"; Shipping=Nlarge*weight*115
Name= Shipping to Kawerau; State=="Kawerau"; Shipping=Nlarge*weight*132
Name= Shipping to Kerikeri; State=="Kerikeri"; Shipping=Nlarge*weight*185
Name= Shipping to Kumeu; State=="Kumeu"; Shipping=Nlarge*weight*76
Name= Shipping to Levin; State=="Levin"; Shipping=Nlarge*weight*145
Name= Shipping to Masterton; State=="Masterton"; Shipping=Nlarge*weight*166
Name= Shipping to MtMaunganui; State=="Mt Maunganui"; Shipping=Nlarge*weight*99
Name= Shipping to Napier; State=="Napier"; Shipping=Nlarge*weight*13
Name= Shipping to NewPlymouth; State=="New Plymouth"; Shipping=Nlarge*weight*123
Name= Shipping to Orewa; State=="Orewa"; Shipping=Nlarge*weight*95
Name= Shipping to Palmerston North; State=="Palmerston North"; Shipping=Nlarge*weight*139
Name= Shipping to Rotorua; State=="Rotorua"; Shipping=Nlarge*weight*98
Name= Shipping to Russell; State=="Russell"; Shipping=Weight*142
Name= Shipping to Silverdale; State=="Silverdale"; Shipping=Nlarge*weight*80
Name= Shipping to Taumaranui; State=="Taumaranui"; Shipping=Nlarge*weight*185
Name= Shipping to Taupo; State=="Taupo"; Shipping=Nlarge*weight*140
Name= Shipping to Tauranga; State=="Tauranga"; Shipping=Nlarge*weight*98
Name= Shipping to Thames; State=="Thames"; Shipping=Nlarge*weight*109
Name= Shipping to Tokoroa; State=="Tokoroa"; Shipping=Nlarge*weight*109
Name= Shipping to Wanganui; State=="Whanganui"; Shipping=Nlarge*weight*166
Name= Shipping to Warkworth; State=="Warkworth"; Shipping=Nlarge*weight*80
Name= Shipping to Wellington; State=="Wellington"; Shipping=Nlarge*weight*199
Name= Shipping to Wellsford; State=="Wellsford"; Shipping=Weight*79
Name= Shipping to Whakatane; State=="Whakatane"; Shipping=Nlarge*weight*142
Name= Shipping to Whangarei; State=="Whangarei"; Shipping=Nlarge*weight*109


South Island
Name= Shipping to Alexandra; State=="Alexandra"; Shipping=Slarge*weight*574
Name= Shipping to Ashburton; State=="Ashburton"; Shipping=Slarge*weight*411
Name= Shipping to Balclutha; State=="Balclutha"; Shipping=Slarge*weight*521
Name= Shipping to Blenheim; State=="Blenheim"; Shipping=Slarge*weight*369
Name= Shipping to Christchurch; State=="Christchurch"; Shipping=Slarge*weight*395
Name= Shipping to Clyde; State=="Clyde"; Shipping=Slarge*weight*520
Name= Shipping to Cromwell; State=="Cromwell"; Shipping=Slarge*weight*475
Name= Shipping to Dunedin; State=="Dunedin"; Shipping=Slarge*weight*370
Name= Shipping to Gore; State=="Gore"; Shipping=Slarge*weight*490
Name= Shipping to Greymouth; State=="Greymouth"; Shipping=Slarge*weight*404
Name= Shipping to Invercargill; State=="Invercargill"; Shipping=Slarge*weight*460
Name= Shipping to Nelson; State=="Nelson"; Shipping=Slarge*weight*380
Name= Shipping to Oamaru; State=="Oamaru"; Shipping=Slarge*weight*400
Name= Shipping to Queenstown; State=="Queenstown"; Shipping=Slarge*weight*586
Name= Shipping to Rangiora; State=="Rangiora"; Shipping=Slarge*weight*440
Name= Shipping to Timaru; State=="Timaru"; Shipping=Slarge*weight*369
Name= Shipping to Wanaka; State=="Wanaka"; Shipping=Slarge*weight*586
Name= Shipping to Washdyke; State=="Washdyke"; Shipping=Slarge*weight*339
Name= Shipping to Westport; State=="Westport"; Shipping=Slarge*weight*390
Attachments:

Using width to set the price 24 Jun 2017 22:01 #13

Dear Gareth,
Thanks for the full set of rules. I'm afraid I have not fully understood your shipping cost structure yet.

I think I understand parts your problem now. You want to set different shipping costs for each small item, and to achieve this, you "abuse" the weight variable to store the shipping costs there. Is this correct?

On the other hand, the weight variable is already the sum of all weights of the total order (and not the individual weight of each product), so it contains already the cumulated weight of all products (not restricted to large or small items). So multiplying it by the number of articles is not required any more. If you use the weight variable to store shipping costs, then you don't need the number of small items (the evaluate_for_categories(Articles, 28) call), but rather the "weight" of all small items.

So, you actually do NOT want the number of large items stored in Slarge or Nlarge and then multiplied by weight, but you rather want the sum of all Weights of the north/south-warehouse-based large items. Similarly for the small items: You don't want the number of small articles and then multiply it with the weight, but you want the total "weight" of all small items (which indicates your shipping costs):
Variable=Nlarge; Value=evaluate_for_categories(Weight, 23)
Variable=Slarge; Value=evaluate_for_categories(Weight, 25)
Variable=Courier; Value=evaluate_for_categories(Weight, 28)

Name= Shipping to Auckland; State=="Auckland"; Shipping=Nlarge*65 + Courier*10


Name= Shipping to Auckland - Silverdale; State=="Auckland - Silverdale"; Shipping=Nlarge*85 + Courier*10
Name= Shipping to Auckland - Warkworth; State=="Auckland - Warkworth"; Shipping=Nlarge*85 + Courier*10
...

Let's look at an example: A customer from the southern island buys two pool tables from category 23 (one has weight set to 1, the other has weight set to 1.5) and two small items from category 28, both with weight set to 0.3:
-) The Nlarge variable will have the value 2.5 (1 from the first, 1.5 from the second pool table). The number of tables is already implicitly used, because the individual "weights" of the pool tables are summed. => Shippign cost for the large tables will be 2.5*85=212.5
-) The Slarge variable will be 0.
-) The Courier variable will be 0.6 (0.3 from each of the two small items). => Shipping for small items will be 6
-) => The total shipping costs are 2.5*85+0.6*10=218.5


Best regards,
Reinhold
  • Page:
  • 1