【发布时间】:2015-04-16 14:59:14
【问题描述】:
我正在 Magento 外部编写一个单独的 php 文件来支持我们的本地应用程序。
应用优惠券代码部分不适合我。但同样的优惠券也适用于 Magento(userend) 和 Magento API 调用。
我正在尝试使用 Magento 在 API 中的相同代码。
$quoteId = 10001;
$coupon = 'TESTCOUPON';
$storeId = 2;
$quote = Mage::getModel("sales/quote");
$quote->setStoreId($storeId);
$quote->load($quoteId);
if (!$quote->getItemsCount()) {
echo ('quote_is_empty');
exit;
}
$quote->getShippingAddress()->setCollectShippingRates(true);
$quote->setCouponCode($coupon)
->collectTotals()
->save();
if (!$coupon == $quote->getCouponCode()) {
echo ('coupon_code_is_not_valid');
exit;
}
else{
echo 'coupon applied';
exit;
}
以上代码通过coupon_code_is_not_valid。 如果有人对此有任何想法,请告诉我。
【问题讨论】:
-
您想在订购产品时获取优惠券代码吗?
-
是的,在产品添加到购物车/报价后。
-
你的代码是正确的,你遇到了什么问题?
-
当我通过 coupon_code_is_not_valid 运行代码时
-
在不区分大小写模式下比较字符串