Z
Z
z1mak2016-09-21 13:09:22
Delivery
z1mak, 2016-09-21 13:09:22

How to add the cost of a box, pallet for transportation depending on the number of products in WooCommerce?

Hello, I'm facing a shipping issue with WooCommerce.
I looked for ready-made plugins, looked on the forums for what they write about it, until I found nothing suitable.
The essence of the problem:
1. It is necessary to add to the cost of the product and its delivery (in this case, depending on the weight and end point) - a separate fee for the box (pallet) for this delivery for a separate category of products.
The cost of the box (pallet) needs to be included only every 12 items (because such a quantity fits in the box). And with all this, you need to cancel the separate fee for the delivery of these 12 items separately, because they will no longer go separately and in 1 large pallet. And all this for certain categories of goods.
In general, you need to insert approximately the following code, only there will still be a check for the category of goods. And that's just to get the point across.
The cost of delivery of 1 unit of goods is 10 cu.
The price of delivery for every 12 units of goods is 100 cu (discount for 20)

<script>

var shippingPrice = 0;
var item  = 0;
function culculateShippingPrice(x){

  if(x <= 11){
    shippingPrice = x * 10;
  } 
  else if (x % 12 == 0){
    shippingPrice = (x / 12) * 100;
  }
  else if (x % 12 <= 11){
    item = x % 12;
    shippingPrice = ((x - item) / 12) * 100 + item * 10;
}
document.write( "Всего ящиков для перевозки: " + x + "<br>");
document.write( "Стоимость перевозки: " + shippingPrice);
}

culculateShippingPrice(25);

</script>

Perhaps someone has come across a similar one, not a WooCommerce guru, which is why I am writing here. There is absolutely no time to figure everything out on your own.
Perhaps someone will tell you a plugin or at least a direction where to look. Thank you for your attention !

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question