我想创建一个特定的模块来添加定制产品。这样,我开发了下一个源代码(正在运行):
/* Data */
$id_product = (int)Tools::getValue('id_product');
$id_customization = (int)Tools::getValue('id_customization'); // = 0
$price_product = (int)Tools::getValue('priceform'); // nouveau prix
/* Create the cart */
if(!$this->context->cart->id) {
/* Detect the user logged */
if($this->context->cookie->id_guest) {
$guest = new Guest($this->context->cookie->id_guest);
$this->context->cart->mobile_theme = $guest->mobile_theme;
}
$this->context->cart->add();
/* Create the cookie */
if($this->context->cart->id) {
$this->context->cookie->id_cart = (int)$this->context->cart->id;
}
}
/* Select the cart */
$cart = $this->context->cart;
/* Select the product */
$product = new Product($id_product, true, (int)($this->context->cookie->id_lang));
$id_product_attribute = Product::getDefaultAttribute($id_product);
/* Add to cart */
$cart->updateQty(1, $id_product, $id_product_attribute, $id_customization);
但是我不知道如何更改价格,添加磁偏角($ _POST ['group [X]'])并添加更多信息(字符串/ varchar)?
答案 0 :(得分:0)
要更改价格,您可以使用:
$product->price = your price here;
$product->update();