2017-12-25 11 views

答えて

0

これは私のため

$pr = CoreCommerceProduct::getByID(10); //id of product 
    $cart = CoreCommerceCurrentOrder::get(); 

    // add the product to the cart 
    $pr = $cart->addProduct($pr, $qty); 

    $eventResult = Events::fire('core_commerce_add_to_cart', $cart, $pr, $qty); 

    // append attributes to order product 
    $attribs = $pr->getProductConfigurableAttributes(); 
    foreach ($attribs as $at) { 
     $at->saveAttributeForm($pr); 
    } 

    $pr->rescanOrderProductPricePaid(); 

    // decide wether to increment quantity or add additional line item 
    if ($other = $cart->orderContainsOtherProduct($pr)) { 
     $cart->removeProduct($pr); 
     if (!$other->productIsPhysicalGood()) { 
      $newQuant = 1; 
     } else { 
      $newQuant = $other->getQuantity() + $qty; 
     } 
     $other->setQuantity($newQuant); 
    } 
の作品
関連する問題