Question

J'ai développé un script personnalisé pour passer des commandes dans Magento.Comment puis-je appliquer une carte-cadeau au panier (devis) par programmation ?Je ne vois aucun code associé.

Était-ce utile?

La solution

Veuillez essayer le code ci-dessous

    $giftcardAccountCode = "Abc";
    $storeId = 1;
    $quoteId = 201;

    $quote = Mage::getModel("sales/quote");

    $quote->setStoreId($storeId)
                ->load($quoteId);

    /** @var $giftcardAccount Enterprise_GiftCardAccount_Model_Giftcardaccount */
    $giftcardAccount = Mage::getModel('enterprise_giftcardaccount/giftcardaccount')
            ->loadByCode($giftcardAccountCode);
    if (!$giftcardAccount->getId()) {
        Mage::throwException('Giftcard Account Not Found  By Code');
    }
    try {
        $giftcardAccount->addToCart(true, $quote);
    } catch (Exception $e) {
        $e->getMessage();
    }
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top