Change Flat Rate shipping cost based on attribute values count in WooCommerce

Viewed 2864

I'm trying to specify 2 different Flat rates shipping methods costs without using a plugin:

  • If there is a product in the cart from only one Vendor, the Flat rate shipping cost needs to be £19.
  • If there are multiple products in the cart from more than one Vendor, the Flat rate shipping cost needs to be £39.

I have tried various plugins, but they focus on shipping rates based on size, weight, quantity, location, category, but not Attributes or Terms.

I have an Attribute named Vendor with 8 Terms. Each Term is a different Vendor/supplier.

Here's the type of PHP logic I would like to implement:

if product attribute term quantity = 1

then flat rate = £19

else

if product attribute term quantity > 1

then flat rate = £39

How can I change this "Flat rate" shipping method cost when there is more than 1 attribute Vendor terms in cart?

1 Answers
Related