Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

How to retrieve the highest shipping class in cart

$
0
0

Replies: 0

I’m trying to add a 50% discount to all shipping classes in cart other than the highest shipping class.

If I have 3 products in the cart, each with its own shipping class pricing like P1=$150; P2=$200; P3=$300. Expected sum of shipping costs would be: (P1/50%)+(P2/50%)+P3(most expensive)= $475

I wrote a function to discount a specific class via shipping class slug. But I don’t know how to retrieve the highest (most expensive) shipping class in a cart and discount all other shipping classes by 50%, because each time there may be a different shipping class (with different slug) in a cart that is most expensive.

Is there a method to discount all shipping class prices on cart other than the most expensive one?


Viewing all articles
Browse latest Browse all 59525

Trending Articles