相关疑难解决方法(0)

Prestashop:将定制产品添加到购物车

我写了一个Prestashop的自定义控制器。可以完成一个简单的任务:1.如果尚未创建新购物车(工作正常)2.从数据库获取属性ID(工作正常)3.分配自定义(一个文本字段)4.添加此产品购物车。

我当前的代码:

$idProduct = 1; // for me it's always one
$qty= 1; // always add one item
$text = (string)Tools::getValue('textField9'); // string of text customization
$attribute = (int)Tools::getValue('sel_combination'); // atribute combination ID

// get cart id if exists
if ($this->context->cookie->id_cart)
{
    $cart = new Cart($this->context->cookie->id_cart);
}

// create new cart if needed
if (!isset($cart) OR !$cart->id)
{
    $cart = new Cart();
    $cart->id_customer = (int)($this->context->cookie->id_customer);
    $cart->id_address_delivery = (int)  (Address::getFirstCustomerAddressId($cart->id_customer));
    $cart->id_address_invoice = $cart->id_address_delivery;
    $cart->id_lang = (int)($this->context->cookie->id_lang);
    $cart->id_currency = (int)($this->context->cookie->id_currency);
    $cart->id_carrier = …
Run Code Online (Sandbox Code Playgroud)

php cart prestashop

3
推荐指数
1
解决办法
7857
查看次数

标签 统计

cart ×1

php ×1

prestashop ×1