20 minutes ago, 4you.software said:And where do you see that $id_cart is not passed?
$cart = new Cart() => return $cart->id !!
You can also directly call Hook::exec
$cart = new Cart(); /* or $cart = new Cart(int) $id_cart); */ $data = [ 'cart' => $cart, 'product' => $product, 'id_product_attribute' => $id_product_attribute, 'id_customization' => $id_customization, 'quantity' => $quantity, 'operator' => $operator, 'id_address_delivery' => $id_address_delivery, 'shop' => $shop, 'auto_add_cart_rule' => $auto_add_cart_rule, ]; Hook::exec('actionCartUpdateQuantityBefore', $data);
Ok this is interesting.
The problem in your proposition before is that if there is no cart already created the we go in "if(!$id_cart)" and not in the "else" where the updadeQty() is firing. I tried, I need to click 2 times on "Add to shopping cart" to get 1 time the product. The first time we go in "if(!$id_cart)" and create the object, second time we go in "else" as the object is already created and we updateQty().
My problem is not about putting the string in the Cart object, my 1st code does that well. The problem is that when I chose the Carrier in Checkout, the Cart->gift_message data is deleted. And so the hookActionValidateOrder's $params['cart']->gift_message is empty.
I verified in real time in database, the gift_message has my string until the very moment I chose a Carrier.