Prestashop 1.6 - 基于最终总价的免费送货

Prestashop 1.6 - free shipping based on final total price

我正在使用 prestashop 1.6。我的网站提供 "free shipping" 购买 超过 80 美元。我的网站也有 "Buy 1 get 1 free" 的促销活动。

现在,一件商品的价格约为 60 美元,我坚持要求客户购买同一类别的 2 件产品,以便获得买 1 送 1 的资格。

如果客户购买一件产品,应该花费 60 美元(不包邮,因为最终价格 < 80)

如果客户购买了 2 = 120 美元,但在 "buy 1 get 1 free" 促销之后,最终总价为 60。因此,按理说,该客户没有享受免费送货服务,但我的网站为该客户提供免费送货服务因为"free shipping"逻辑是基于打折前的总价(120块)。

我该如何解决这个问题?我要包邮按最终总价计算(打折后)

您必须重写 Cart.php 中的方法 getPackageShippingCost()

并更改这些行:

    } else {
        if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT) {
            $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone);
        } else { // by price
            $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int)$this->id_currency);
        }
    }
} else {
    if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT) {
        $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone);
    } else {
        $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int)$this->id_currency);
    }
}

通过将 $order_total 替换为 $orderTotalwithDiscounts:

    } else {
        if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT) {
            $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone);
        } else { // by price
            $shipping_cost += $carrier->getDeliveryPriceByPrice($orderTotalwithDiscounts, $id_zone, (int)$this->id_currency);
        }
    }
} else {
    if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT) {
        $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone);
    } else {
        $shipping_cost += $carrier->getDeliveryPriceByPrice($orderTotalwithDiscounts, $id_zone, (int)$this->id_currency);
    }
}

如果您不知道如何覆盖 class,请查看 this documentation