我想在將新產品添加到購物車後使購物車訂單清空。其實只有產品每次都可以在購物車中購買。 坦Prestashop:如何清空購物車?
0
A
回答
4
2的方法來添加自定義邏輯:
- 創建自己的模塊,並把它掛在「actionCartSave」
-
覆蓋「添加」,在「購物車」類「更新」的方法( /override/classes/Cartp.php)
編輯:第二種方式os錯誤,因爲無限更新循環。
這裏是一個模塊,這樣做:
class OneProductCart extends Module {
public function __construct() {
$this->name = 'oneproductcart';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'SJousse';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('One Product Cart');
$this->description = $this->l('Keep only last product in cart.');
}
public function install() {
return (parent::install() && $this->registerHook('actionCartSave'));
}
public function hookActionCartSave($params) {
$cart = $params['cart'];
$last = $cart->getLastProduct();
$prods = $cart->getProducts();
foreach ($prods as $prod)
if ($prod['id_product'] != $last['id_product'])
$cart->deleteProduct($prod['id_product']);
}
}
1
對於正在使用的Prestashop v 1.4.9並創建了一個模塊:
呼叫global $smarty, $cart;
然後運行功能$cart->delete();
function hookHome($params)
{
global $smarty, $cart;
/** some code here **/
$cart->delete();
}
相關問題
- 1. Prestashop購物車
- 2. 購物車清空15件物品
- 3. Prestashop購物車不工作
- 4. 如何限制購物車產品Prestashop
- 5. 如何獲取購物車內容? (prestashop)
- 6. Magento購物車:檢查商品清空購物車
- 7. 點擊「添加到購物車」按鈕時如何讓購物車清空
- 8. 「購物車塊」和「添加到購物車」按鈕消失Prestashop
- 9. 的Prestashop塊購物車和購物車控制器
- 10. 如何清除購物車中的cartitems
- 11. 如何清除Woocommerce購物車
- 12. Magento:購物車清單
- 13. 清除Prestashop購物車如果購物車特定類別中的最後一個產品
- 14. Prestashop「加入購物車」由crawler訪問?
- 15. Prestashop webservice API創建購物車規則
- 16. Prestashop加入購物車功能
- 17. 購物車重定向Prestashop非Ajax
- 18. woocommerce菜單購物車,當購物車空時如何隱藏購物車標籤
- 19. 使用Magento SOAP API訂購後清空購物車
- 20. 當購物車不空時設置購物車鏈接
- 21. Magento:添加到購物車顯示空的購物車
- 22. 迷你購物車中的空購物車按鈕。 woocommerce
- 23. 如何從購物車的Prestashop獲得總重量
- 24. 如何單擊添加到購物車中的Prestashop
- 25. 如何更改HTTP到HTTPS在的Prestashop 1.6加入購物車
- 26. 如何在ajax-cart.js(prestashop模塊)中獲取購物車ID
- 27. Prestashop api - 如何獲取當前購物車內容
- 28. 如何在prestashop中爲客戶自動創建購物車?
- 29. 如何更改prestashop用戶的購物車?
- 30. Prestashop:如何在購物車中顯示消息
$ products = $ this-> getProducts(); \t \t的foreach($產品爲$產品) \t \t { \t \t $這 - > deleteProduct($產品 - > ID); \t \t} – sirramin
我在上面的代碼中使用方法添加在cart.php類 – sirramin