Magento: Convert Quote to Order
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
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.
add a comment |
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
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
add a comment |
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
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
magento-1.9 orders
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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();
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
add a comment |
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);
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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();
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
add a comment |
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();
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
add a comment |
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();
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();
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
add a comment |
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
add a comment |
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);
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
add a comment |
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);
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
add a comment |
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);
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);
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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