프로그래밍 방식으로 장바구니에 항목을 추가하고 게스트 사용자에게 할당

magento.stackexchange https://magento.stackexchange.com//questions/30417

  •  11-12-2019
  •  | 
  •  

문제

코드가 객체를 작성하고 항목 개체를 인용하기 위해 작업을 수행하고 데이터베이스를 확인하여 확인할 수있는 인용구를 성공적으로 만들 수 있습니다. 프런트 엔드라는 쿠키도 생성했습니다.이제 필요한 모든 것은 사용자가 게스트 사용자에게 사용자를 게스트로 할 수 있지만 게스트 사용자에게 장바구니를 할당 할 수 없도록 이제는 작성된 따옴표를 지정하는 것입니다.

장바구니에있는 항목 요청은 제 3 자 사이트에서 제 3 자 사이트에서 제가 디코딩되어 반복 된

여기 코드가

session_name("frontend");

session_start();

$cartInfo = $_GET['items'];

require_once '../app/Mage.php'; 

Mage::init('default');

$session = Mage::getSingleton('customer/session');

Mage::getSingleton('checkout/cart')->getQuote();

foreach ($cartArray as $key=> $value) {
        $productId = $key;
        $productQuantity = $value;
        $productModel = Mage::getSingleton('catalog/product');
        $productObj = $productModel->load($productId);
        if (!$quoteObj) {
            $quoteObj = new Mage_Sales_Model_Quote();
        }

        $store_id = Mage::app()->getStore()->getId();
        $storeObj = $quoteObj->getStore()->load($store_id);
        $quoteObj->setStore($storeObj);

        $quoteItem = Mage::getModel('sales/quote_item')->setProduct($productObj);
        $quoteItem->setQuote($quoteObj);
        $quoteItem->setQty($productQuantity);
        $quoteItem->setStoreId($store_id);

        $quoteObj->addItem($quoteItem);
        $quoteObj->setStoreId($store_id);
        $quoteObj->collectTotals();
        $quoteObj->setCustomerId(null);
        $quoteObj->save();
        $quoteId = $quoteObj->entity_id;
        echo $quoteObj->entity_id.'**<br />';
        echo $quoteItem->item_id.'---<br />';
}
.

도움이 되었습니까?

해결책

마침내 문제를 알아 냈습니다. 누군가가 도움이되기를 바랍니다.

위에서 해당 코드가 완벽하게 작동하므로 Magento 설치의 루트 폴더에 사용자 정의 파일을 배치하고 폴더를 만들고이 코드를 배치하면 작동하지 않습니다.코드 파일이 루트에 있어야합니다.

다른 팁

이것은 추측 체크 아웃이기 때문에, 내가 생각할 수있는 유일한 방법은 고객이 브라우저에서 견적을 다시로드하게하는 것입니다.따라서 견적 ID와 링크를 이메일로 보내거나 사이트의 견적 ID를 입력하도록하십시오.

컨트롤러에서 따옴표를 다시로드하려면

 $id = $this->getRequest()->getParam('quote_id');
 $store_id = $this->getRequest()->getParam('store_id');

 ....   
 $this->_getSession()->clear();
 $this->_getQuote()
      ->setQuoteId($id)
      ->setStoreId($store_id)
      ->setIsActive(true)
      ->load($id);
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top