You are here:  » Filter for shipping cost depending on product price


Filter for shipping cost depending on product price

Submitted by sirmanu on Tue, 2018-01-09 22:27 in

Hi David. Is any filter to establish shipping cost depending on the value of product price?
I mean, I have some merchants where shipping cost is free on orders over X quantity, and for orders under X, you must pay some quantity.
How can I achieve this?
Thank you!

Submitted by support on Wed, 2018-01-10 09:48

Hi,

If not already in place, first edit includes/admin.php and look for the following code at line 148:

    global $filter_record;

...and REPLACE with:

    global $filter_record;
    global $importRecord;

This will give access to the price field being imported for a new "Shipping" filter, to set a fixed value or "0.00" if price is greater than or equal to a minimum spend for free shipping. To add the filter, add the following code to includes/filter.php:

  /*************************************************/
  /* Shipping */
  /*************************************************/
  $filter_names["shipping"] = "Shipping";
  function filter_shippingConfigure($filter_data)
  {
    widget_textBox("Shipping Cost","cost",TRUE,$filter_data["cost"],"",6);
    widget_textBox("Free Shipping Minimum Spend","free",TRUE,$filter_data["free"],"",6);
  }
  function filter_shippingValidate($filter_data)
  {
  }
  function filter_shippingExec($filter_data,$text)
  {
    global $importRecord;
    $price = tapestry_decimalise($importRecord["price"]);
    return ($price >= $filter_data["free"]?"0.00":$filter_data["cost"]);
  }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by sirmanu on Wed, 2018-01-10 21:54

Thank you David.
It is working as expected.