2016-05-05 3 views
0

Ниже мой код: -Как получить текущие элементы корзины для зарегистрированного пользователя

try 
 
      { 
 
       $store = $this->_getStore(); 
 
       Mage::app()->setCurrentStore($store->getId()); 
 
       $customer_ID = 3; 
 
       $customer = Mage::getModel('customer/customer')->load($customer_ID); 
 

 
       // load quote by customer 
 
       $quote = Mage::getModel('sales/quote')->loadByCustomer($customer_ID); 
 

 
       $quote->assignCustomer($customer); 
 
       $product = Mage::getModel('catalog/product') 
 
         // set the current store ID 
 
         ->setStoreId(Mage::app()->getStore()->getId()) 
 
         // load the product object 
 
         ->load(3); 
 

 
       // Add Product to Quote 
 
       $quote->addProduct($product,1); 
 

 
       // Calculate the new Cart total and Save Quote 
 
       $quote->collectTotals()->save(); 
 
    
 
       return json_encode(array("", $quote->getId())); 
 
       
 
      }catch(Exception $e) 
 
      { 
 
       return $e->getMessage();; 
 
      }

Используя этот продукт становится добавлен в корзину успешно и возвращающегося quote_id, но используя этот идентификатор Я хочу получать текущие данные о товарах для зарегистрированных пользователей.

ответ

2

Чтобы получить подробную информацию Корзина пункт:

$quote = Mage::helper('checkout/cart')->getCart()->getQuote(); 
$value = []; 
foreach ($quote->getAllItems() as $item) { 
$value[]= array (
'id' => $item->getSku(), 
'quantity' => $item->getQty(), 
'price' => $item->getParentItemId()? $item->getParentItem()->getPrice(): $item->getPrice() 
); 
    } 
+0

благодаря она работала, я понравился ваш ответ –

+0

я отправляю еще один вопрос вы можете, пожалуйста, помогите мне с ним тоже. В ближайшее время я дам вам ссылку на вопрос, буду очень благодарен. –

+0

Biplab это ссылка на вопрос: - http://stackoverflow.com/questions/37185236/editing-customer-address-based-on-address-id-and-customer-id-in-magento –

Смежные вопросы