항목은 주문형 주문을 할 때 주문시 $ 0.00 가격이 있습니다.
문제
그래서, 나는 Magento 1.12 EE에서 프로그래밍 방식으로 명령을 만들려고 노력하고 있습니다.나는 제품을로드하고 가격 속성이 올바른 값을 보유하고 있는지 확인할 수 있습니다.항목을 카트에 추가하면 가격이 $ 0.00으로 변경됩니다.다음은 내가 사용하는 스크립트가 있습니다 :
$customer = Mage::getModel('customer/customer');
$customAddress = ...;
//set customer data and log in customer, left out for this post
$checkout_session = Mage::getSingleton('checkout/session');
$quote = $checkout_session->getQuote();
$checkout_session->getQuote()
->setBillingAddress(Mage::getSingleton('sales/quote_address')
->importCustomerAddress($customAddress));
$product = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('entity_id', '634887')
->addAttributeToSelect('*')
->getFirstItem();
echo "product price: " . $product->getPrice() . "<br>";
//prints correct price
$pid = $product->getId();
$product->load($pid);
$cart = Mage::getSingleton('checkout/cart');
$cart->truncate();
$cart->save();
$cart->getItems()->clear()->save();
try {
$cart->addProduct($product->getId(), array('qty'=>1));
$cart->save();
print "product added <br>";
}
catch (Exception $ex) {
echo "product error " . $ex->getMessage() . "<br>";
}
$cart_grand_total = $cart->getQuote()->getGrandTotal();
$quote_grand_total = $quote->getGrandTotal();
$cart_items = $cart->getItems()->getData();
$quote_data = $quote->getData();
echo "CART GRAND TOTAL<br>";
var_dump($cart_grand_total);
//returns 0
echo "CHECKOUT SESSION QUOTE GRAND TOTAL<br>";
var_dump($quote_grand_total);
//returns 0
echo "CART ITEMS DUMP<br>";
var_dump($cart_items);
//shows item price as 0.00
echo "CHECKOUT SESSION QUOTE DATA DUMP<br>";
var_dump($quote_data);
//shows grand total = 0
.
장바구니에 추가되기 전에 상품이 올바른 가격으로 진행되는 이유에 대한 아이디어가 있으시면 장바구니에있을 때 $ 0.00 가격이됩니다.
어떤 도움에도 미리 감사드립니다.
해결책
코드 에서이 행을 제거하고 주문 합계가 나타납니다.어떻게 든 그들은 장바구니가 합계를 얻지 못하게하는 것입니다.
$cart->save();
$cart->getItems()->clear()->save();
. 다른 팁
일부 시점에서 합계를 수집해야합니다.주문을 작성하는 코드를 얻지 못했지만 "Nofollow"> 이것을 확신 할 수는 없습니다. 가이드는 매우 유용하고 과거에 나를 위해 일했습니다. 어쨌든 시도해보십시오
$quote->collectTotals()->save();
.
제품을 장바구니에 추가 한 후
제휴하지 않습니다 magento.stackexchange