Magento: Convert Quote to Order












4














I want to create order from quote id . I am using this code but order is not getting created



$quote = Mage::getModel('sales/quote')->load(94251);
$convertQuote = Mage::getSingleton('sales/convert_quote');
$order = $convertQuote->toOrder($quote);


I get error that Credit card number mismatch with credit card type. payment method already store in quote. payment method is authnetcim.










share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • pls try my answer and let me know it works or not.
    – Nikunj Vadariya
    Oct 20 '16 at 11:28










  • Anyone have solution for this??
    – Jigs Parmar
    Oct 30 '17 at 3:22
















4














I want to create order from quote id . I am using this code but order is not getting created



$quote = Mage::getModel('sales/quote')->load(94251);
$convertQuote = Mage::getSingleton('sales/convert_quote');
$order = $convertQuote->toOrder($quote);


I get error that Credit card number mismatch with credit card type. payment method already store in quote. payment method is authnetcim.










share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • pls try my answer and let me know it works or not.
    – Nikunj Vadariya
    Oct 20 '16 at 11:28










  • Anyone have solution for this??
    – Jigs Parmar
    Oct 30 '17 at 3:22














4












4








4







I want to create order from quote id . I am using this code but order is not getting created



$quote = Mage::getModel('sales/quote')->load(94251);
$convertQuote = Mage::getSingleton('sales/convert_quote');
$order = $convertQuote->toOrder($quote);


I get error that Credit card number mismatch with credit card type. payment method already store in quote. payment method is authnetcim.










share|improve this question















I want to create order from quote id . I am using this code but order is not getting created



$quote = Mage::getModel('sales/quote')->load(94251);
$convertQuote = Mage::getSingleton('sales/convert_quote');
$order = $convertQuote->toOrder($quote);


I get error that Credit card number mismatch with credit card type. payment method already store in quote. payment method is authnetcim.







magento-1.9 orders






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 26 '17 at 11:11









Priyank

5,11341949




5,11341949










asked Oct 20 '16 at 11:08









Jigs Parmar

1,092322




1,092322





bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • pls try my answer and let me know it works or not.
    – Nikunj Vadariya
    Oct 20 '16 at 11:28










  • Anyone have solution for this??
    – Jigs Parmar
    Oct 30 '17 at 3:22


















  • pls try my answer and let me know it works or not.
    – Nikunj Vadariya
    Oct 20 '16 at 11:28










  • Anyone have solution for this??
    – Jigs Parmar
    Oct 30 '17 at 3:22
















pls try my answer and let me know it works or not.
– Nikunj Vadariya
Oct 20 '16 at 11:28




pls try my answer and let me know it works or not.
– Nikunj Vadariya
Oct 20 '16 at 11:28












Anyone have solution for this??
– Jigs Parmar
Oct 30 '17 at 3:22




Anyone have solution for this??
– Jigs Parmar
Oct 30 '17 at 3:22










2 Answers
2






active

oldest

votes


















0














Try something like below :



$store = Mage::getSingleton('core/store')->load(1);

$quote = Mage::getModel('sales/quote')->setStore($store)->load(94251);
$quote->assignCustomer(Mage::getSingleton('customer/session')->getCustomer());

$quote->collectTotals()
->getPayment()->setMethod('purchaseorder');

$convert = Mage::getModel('sales/convert_quote');
$order = $convert->toOrder($quote)
->setBillingAddress(
$convert->addressToOrderAddress($quote->getBillingAddress())
)
->setShippingAddress(
$convert->addressToOrderAddress($quote->getShippingAddress())
)
->setPayment(
$convert->paymentToOrderPayment($quote->getPayment())
);

foreach ($quote->getAllItems() as $quoteItem) {
$orderItem = $convert->itemToOrderItem($quoteItem);
if ($quoteItem->getParentItem()) {
$orderItem->setParentItem(
$order->getItemByQuoteItemId($quoteItem->getParentItem()->getId())
);
}
$order->addItem($orderItem);
}

$order->save();





share|improve this answer





















  • it not works. no any order createa
    – Jigs Parmar
    Oct 20 '16 at 12:05










  • and i not want to store any static information when create order
    – Jigs Parmar
    Oct 20 '16 at 12:05



















0














Here is the script:



$quote = Mage::getModel('sales/quote')->load(5428);

$convert = Mage::getModel('sales/convert_quote');

$order = $convert->toOrder($quote);
$order->addressToOrder($quote->getAddress(),$order);

foreach($quote->getAllItems() as $item){
$orderItem = $convert->itemToOrderItem($item);
if ($item->getParentItem()) {
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
}
$order->addItem($orderItem);
}

$quote->getShippingAddress()->setPaymentMethod('paypal_express');
$quote->getShippingAddress()->setCollectShippingRates(true);

$payment = $quote->getPayment();
$payment->importData($data);
$quote->save();

$payment = $convert->paymentToOrderPayment($quote->getPayment());

$order->setPayment($quote->getPayment());

$message = '[Notice] - Order converted from quote manually';
$order->addStatusToHistory($order->getStatus(), $message);
$order->place();
$order->save();

$quote->setIsActive(false)->save();


Other solution:-



Have you tried the toOrder Method?



http://docs.magentocommerce.com/Mage_Sales/Mage_Sales_Model_Convert_Quote.html#toOrder



EDIT :-



$convertQuote = Mage::getSingleton('sales/convert_quote'); $order = $convertQuote->toOrder($quote);





share|improve this answer





















  • in quote there is all information store already. so no any static info store.
    – Jigs Parmar
    Oct 21 '16 at 3:35










  • Your "other solution" is just the beginning bit of your main solution. It's also the same as what jigs tried already, as shown in his question.
    – Doug McLean
    Dec 7 '17 at 15:23










  • And where does $data come from in the line $payment->importData($data);?
    – Doug McLean
    Dec 7 '17 at 15:44











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f141823%2fmagento-convert-quote-to-order%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Try something like below :



$store = Mage::getSingleton('core/store')->load(1);

$quote = Mage::getModel('sales/quote')->setStore($store)->load(94251);
$quote->assignCustomer(Mage::getSingleton('customer/session')->getCustomer());

$quote->collectTotals()
->getPayment()->setMethod('purchaseorder');

$convert = Mage::getModel('sales/convert_quote');
$order = $convert->toOrder($quote)
->setBillingAddress(
$convert->addressToOrderAddress($quote->getBillingAddress())
)
->setShippingAddress(
$convert->addressToOrderAddress($quote->getShippingAddress())
)
->setPayment(
$convert->paymentToOrderPayment($quote->getPayment())
);

foreach ($quote->getAllItems() as $quoteItem) {
$orderItem = $convert->itemToOrderItem($quoteItem);
if ($quoteItem->getParentItem()) {
$orderItem->setParentItem(
$order->getItemByQuoteItemId($quoteItem->getParentItem()->getId())
);
}
$order->addItem($orderItem);
}

$order->save();





share|improve this answer





















  • it not works. no any order createa
    – Jigs Parmar
    Oct 20 '16 at 12:05










  • and i not want to store any static information when create order
    – Jigs Parmar
    Oct 20 '16 at 12:05
















0














Try something like below :



$store = Mage::getSingleton('core/store')->load(1);

$quote = Mage::getModel('sales/quote')->setStore($store)->load(94251);
$quote->assignCustomer(Mage::getSingleton('customer/session')->getCustomer());

$quote->collectTotals()
->getPayment()->setMethod('purchaseorder');

$convert = Mage::getModel('sales/convert_quote');
$order = $convert->toOrder($quote)
->setBillingAddress(
$convert->addressToOrderAddress($quote->getBillingAddress())
)
->setShippingAddress(
$convert->addressToOrderAddress($quote->getShippingAddress())
)
->setPayment(
$convert->paymentToOrderPayment($quote->getPayment())
);

foreach ($quote->getAllItems() as $quoteItem) {
$orderItem = $convert->itemToOrderItem($quoteItem);
if ($quoteItem->getParentItem()) {
$orderItem->setParentItem(
$order->getItemByQuoteItemId($quoteItem->getParentItem()->getId())
);
}
$order->addItem($orderItem);
}

$order->save();





share|improve this answer





















  • it not works. no any order createa
    – Jigs Parmar
    Oct 20 '16 at 12:05










  • and i not want to store any static information when create order
    – Jigs Parmar
    Oct 20 '16 at 12:05














0












0








0






Try something like below :



$store = Mage::getSingleton('core/store')->load(1);

$quote = Mage::getModel('sales/quote')->setStore($store)->load(94251);
$quote->assignCustomer(Mage::getSingleton('customer/session')->getCustomer());

$quote->collectTotals()
->getPayment()->setMethod('purchaseorder');

$convert = Mage::getModel('sales/convert_quote');
$order = $convert->toOrder($quote)
->setBillingAddress(
$convert->addressToOrderAddress($quote->getBillingAddress())
)
->setShippingAddress(
$convert->addressToOrderAddress($quote->getShippingAddress())
)
->setPayment(
$convert->paymentToOrderPayment($quote->getPayment())
);

foreach ($quote->getAllItems() as $quoteItem) {
$orderItem = $convert->itemToOrderItem($quoteItem);
if ($quoteItem->getParentItem()) {
$orderItem->setParentItem(
$order->getItemByQuoteItemId($quoteItem->getParentItem()->getId())
);
}
$order->addItem($orderItem);
}

$order->save();





share|improve this answer












Try something like below :



$store = Mage::getSingleton('core/store')->load(1);

$quote = Mage::getModel('sales/quote')->setStore($store)->load(94251);
$quote->assignCustomer(Mage::getSingleton('customer/session')->getCustomer());

$quote->collectTotals()
->getPayment()->setMethod('purchaseorder');

$convert = Mage::getModel('sales/convert_quote');
$order = $convert->toOrder($quote)
->setBillingAddress(
$convert->addressToOrderAddress($quote->getBillingAddress())
)
->setShippingAddress(
$convert->addressToOrderAddress($quote->getShippingAddress())
)
->setPayment(
$convert->paymentToOrderPayment($quote->getPayment())
);

foreach ($quote->getAllItems() as $quoteItem) {
$orderItem = $convert->itemToOrderItem($quoteItem);
if ($quoteItem->getParentItem()) {
$orderItem->setParentItem(
$order->getItemByQuoteItemId($quoteItem->getParentItem()->getId())
);
}
$order->addItem($orderItem);
}

$order->save();






share|improve this answer












share|improve this answer



share|improve this answer










answered Oct 20 '16 at 11:26









Nikunj Vadariya

2,7821721




2,7821721












  • it not works. no any order createa
    – Jigs Parmar
    Oct 20 '16 at 12:05










  • and i not want to store any static information when create order
    – Jigs Parmar
    Oct 20 '16 at 12:05


















  • it not works. no any order createa
    – Jigs Parmar
    Oct 20 '16 at 12:05










  • and i not want to store any static information when create order
    – Jigs Parmar
    Oct 20 '16 at 12:05
















it not works. no any order createa
– Jigs Parmar
Oct 20 '16 at 12:05




it not works. no any order createa
– Jigs Parmar
Oct 20 '16 at 12:05












and i not want to store any static information when create order
– Jigs Parmar
Oct 20 '16 at 12:05




and i not want to store any static information when create order
– Jigs Parmar
Oct 20 '16 at 12:05













0














Here is the script:



$quote = Mage::getModel('sales/quote')->load(5428);

$convert = Mage::getModel('sales/convert_quote');

$order = $convert->toOrder($quote);
$order->addressToOrder($quote->getAddress(),$order);

foreach($quote->getAllItems() as $item){
$orderItem = $convert->itemToOrderItem($item);
if ($item->getParentItem()) {
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
}
$order->addItem($orderItem);
}

$quote->getShippingAddress()->setPaymentMethod('paypal_express');
$quote->getShippingAddress()->setCollectShippingRates(true);

$payment = $quote->getPayment();
$payment->importData($data);
$quote->save();

$payment = $convert->paymentToOrderPayment($quote->getPayment());

$order->setPayment($quote->getPayment());

$message = '[Notice] - Order converted from quote manually';
$order->addStatusToHistory($order->getStatus(), $message);
$order->place();
$order->save();

$quote->setIsActive(false)->save();


Other solution:-



Have you tried the toOrder Method?



http://docs.magentocommerce.com/Mage_Sales/Mage_Sales_Model_Convert_Quote.html#toOrder



EDIT :-



$convertQuote = Mage::getSingleton('sales/convert_quote'); $order = $convertQuote->toOrder($quote);





share|improve this answer





















  • in quote there is all information store already. so no any static info store.
    – Jigs Parmar
    Oct 21 '16 at 3:35










  • Your "other solution" is just the beginning bit of your main solution. It's also the same as what jigs tried already, as shown in his question.
    – Doug McLean
    Dec 7 '17 at 15:23










  • And where does $data come from in the line $payment->importData($data);?
    – Doug McLean
    Dec 7 '17 at 15:44
















0














Here is the script:



$quote = Mage::getModel('sales/quote')->load(5428);

$convert = Mage::getModel('sales/convert_quote');

$order = $convert->toOrder($quote);
$order->addressToOrder($quote->getAddress(),$order);

foreach($quote->getAllItems() as $item){
$orderItem = $convert->itemToOrderItem($item);
if ($item->getParentItem()) {
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
}
$order->addItem($orderItem);
}

$quote->getShippingAddress()->setPaymentMethod('paypal_express');
$quote->getShippingAddress()->setCollectShippingRates(true);

$payment = $quote->getPayment();
$payment->importData($data);
$quote->save();

$payment = $convert->paymentToOrderPayment($quote->getPayment());

$order->setPayment($quote->getPayment());

$message = '[Notice] - Order converted from quote manually';
$order->addStatusToHistory($order->getStatus(), $message);
$order->place();
$order->save();

$quote->setIsActive(false)->save();


Other solution:-



Have you tried the toOrder Method?



http://docs.magentocommerce.com/Mage_Sales/Mage_Sales_Model_Convert_Quote.html#toOrder



EDIT :-



$convertQuote = Mage::getSingleton('sales/convert_quote'); $order = $convertQuote->toOrder($quote);





share|improve this answer





















  • in quote there is all information store already. so no any static info store.
    – Jigs Parmar
    Oct 21 '16 at 3:35










  • Your "other solution" is just the beginning bit of your main solution. It's also the same as what jigs tried already, as shown in his question.
    – Doug McLean
    Dec 7 '17 at 15:23










  • And where does $data come from in the line $payment->importData($data);?
    – Doug McLean
    Dec 7 '17 at 15:44














0












0








0






Here is the script:



$quote = Mage::getModel('sales/quote')->load(5428);

$convert = Mage::getModel('sales/convert_quote');

$order = $convert->toOrder($quote);
$order->addressToOrder($quote->getAddress(),$order);

foreach($quote->getAllItems() as $item){
$orderItem = $convert->itemToOrderItem($item);
if ($item->getParentItem()) {
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
}
$order->addItem($orderItem);
}

$quote->getShippingAddress()->setPaymentMethod('paypal_express');
$quote->getShippingAddress()->setCollectShippingRates(true);

$payment = $quote->getPayment();
$payment->importData($data);
$quote->save();

$payment = $convert->paymentToOrderPayment($quote->getPayment());

$order->setPayment($quote->getPayment());

$message = '[Notice] - Order converted from quote manually';
$order->addStatusToHistory($order->getStatus(), $message);
$order->place();
$order->save();

$quote->setIsActive(false)->save();


Other solution:-



Have you tried the toOrder Method?



http://docs.magentocommerce.com/Mage_Sales/Mage_Sales_Model_Convert_Quote.html#toOrder



EDIT :-



$convertQuote = Mage::getSingleton('sales/convert_quote'); $order = $convertQuote->toOrder($quote);





share|improve this answer












Here is the script:



$quote = Mage::getModel('sales/quote')->load(5428);

$convert = Mage::getModel('sales/convert_quote');

$order = $convert->toOrder($quote);
$order->addressToOrder($quote->getAddress(),$order);

foreach($quote->getAllItems() as $item){
$orderItem = $convert->itemToOrderItem($item);
if ($item->getParentItem()) {
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
}
$order->addItem($orderItem);
}

$quote->getShippingAddress()->setPaymentMethod('paypal_express');
$quote->getShippingAddress()->setCollectShippingRates(true);

$payment = $quote->getPayment();
$payment->importData($data);
$quote->save();

$payment = $convert->paymentToOrderPayment($quote->getPayment());

$order->setPayment($quote->getPayment());

$message = '[Notice] - Order converted from quote manually';
$order->addStatusToHistory($order->getStatus(), $message);
$order->place();
$order->save();

$quote->setIsActive(false)->save();


Other solution:-



Have you tried the toOrder Method?



http://docs.magentocommerce.com/Mage_Sales/Mage_Sales_Model_Convert_Quote.html#toOrder



EDIT :-



$convertQuote = Mage::getSingleton('sales/convert_quote'); $order = $convertQuote->toOrder($quote);






share|improve this answer












share|improve this answer



share|improve this answer










answered Oct 20 '16 at 12:51









Abhinav Singh

2,007610




2,007610












  • in quote there is all information store already. so no any static info store.
    – Jigs Parmar
    Oct 21 '16 at 3:35










  • Your "other solution" is just the beginning bit of your main solution. It's also the same as what jigs tried already, as shown in his question.
    – Doug McLean
    Dec 7 '17 at 15:23










  • And where does $data come from in the line $payment->importData($data);?
    – Doug McLean
    Dec 7 '17 at 15:44


















  • in quote there is all information store already. so no any static info store.
    – Jigs Parmar
    Oct 21 '16 at 3:35










  • Your "other solution" is just the beginning bit of your main solution. It's also the same as what jigs tried already, as shown in his question.
    – Doug McLean
    Dec 7 '17 at 15:23










  • And where does $data come from in the line $payment->importData($data);?
    – Doug McLean
    Dec 7 '17 at 15:44
















in quote there is all information store already. so no any static info store.
– Jigs Parmar
Oct 21 '16 at 3:35




in quote there is all information store already. so no any static info store.
– Jigs Parmar
Oct 21 '16 at 3:35












Your "other solution" is just the beginning bit of your main solution. It's also the same as what jigs tried already, as shown in his question.
– Doug McLean
Dec 7 '17 at 15:23




Your "other solution" is just the beginning bit of your main solution. It's also the same as what jigs tried already, as shown in his question.
– Doug McLean
Dec 7 '17 at 15:23












And where does $data come from in the line $payment->importData($data);?
– Doug McLean
Dec 7 '17 at 15:44




And where does $data come from in the line $payment->importData($data);?
– Doug McLean
Dec 7 '17 at 15:44


















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f141823%2fmagento-convert-quote-to-order%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

An IMO inspired problem

Management

Investment