5
我要包裝的產品添加到購物車編程,我在ModuleFrontController
行動被認爲是這樣的:如何添加新產品包到購物車?
public function initPack(){
$product = new Pack();
$product->tax_name = 'tva1';
$product->tax_rate = '10%';
$product->id_manufacturer = 1;
$product->id_supplier = 1;
$product->id_category_default = 1;
$product->id_shop_default = 1;
$product->manufacturer_name = 'rrr';
$product->supplier_name = 'rrr';
$product->name = array((int)Configuration::get('PS_LANG_DEFAULT') => 'coffret-4');;
$product->description = 'description 1';
$product->description_short = 'description short';
$product->quantity = 20;
$product->on_sale = false;
$product->online_only = true;
$product->reference = '1234567889';
$product->ean13 = 12233;
$product->upc = 12233;
$product->link_rewrite = array((int)Configuration::get('PS_LANG_DEFAULT') => 'coffret-4');
$product->meta_description = 'fff';
$product->meta_keywords = 'ff';
$product->meta_title = 'fff';
$product->visibility= 'both';
$product->date_add = date("j, n, Y");
$product->location = '';
$product->category = 16;
$product->text_fields = 1;
$product->condition = 'new';
$product->on_sale = true;
if($product->save())
$product->add();
else{
echo 'erooooooor';
die();
}
Pack::addItem($product->id, 1, 1);
Pack::addItem($product->id, 3, 1);
$attribute = $product->addProductAttribute(12, 234, 2344, 12, 20, 1, 222,
$id_supplier = null, 222, 1);
$cart->add($product, array('qty' => 1));
$cart->save();
}
購物車商品的數量遞增,但沒有名稱,價格,...顯示