本文介绍了如何获取在prestashop中应用的优惠券的折扣金额代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我附上以下prestashop购物车的快照,因此我将如何从兑换的凭单中获得折扣金额的代码.
I am attaching the below snapshots of prestashop shopping cart So how I will get the code of discount amount from the voucher redeemed.
推荐答案
您可以使用getCartRules()
函数来获取应用于任何购物车的所有购物车规则.该功能在Cart.php类文件中定义.
You can use the getCartRules()
function to fetch all the cart rules applied on any cart. This function is defined in the Cart.php class file.
您可以使用以下代码来获取当前购物车上的所有优惠券详细信息:
You can use the following code to fetch all the coupon details on current cart:
$this->context->cart->getCartRules();
,您可以使用以下代码来了解客户是否是首次使用优惠券.
and you can use below code to know if the customer is using the voucher for the first time.
if ($context->cart->id_customer) {
$quantityUsed = Db::getInstance()->getValue('
SELECT count(*)
FROM '._DB_PREFIX_.'orders o
LEFT JOIN '._DB_PREFIX_.'order_cart_rule od ON o.id_order = od.id_order
WHERE o.id_customer = '.$context->cart->id_customer.'
AND od.id_cart_rule = '.(int)$this->id.'
AND '.(int)Configuration::get('PS_OS_ERROR').' != o.current_state
');
if ($quantityUsed == 0) {
// Customer is using the coupon for first time.
}
}
这篇关于如何获取在prestashop中应用的优惠券的折扣金额代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!