Override PlaceOrder and change Grand TotalGet Order Info at the ordering moment and send out invoiceMagento update quote item change row totalHow to get order Grand Total from information about order's items (products)?Magento 2.1: How to handle custom payment grand total mismatch upon return to the merchant ?siteMagento 2 - Change maximum order amountMagento 2: How can I update tax and total programmatically on checkout?Magento2 - Override Template order summary in sales email orderCorrect admin menu location for an “Order Attributes” extension for Magento 2Magento 2 : How to change the quantity of items in the checkout?How to create duplicate new quote from old order quote Magento 1.7?
How did old MS-DOS games utilize various graphic cards?
How can I remove material from this wood beam?
60s or 70s novel about Empire of Man making 1st contact with 1st discovered alien race
Fixing obscure 8080 emulator bug?
How can I end combat quickly when the outcome is inevitable?
sed + add word before string only if not exists
How to extend shading in this figure?
New pedal fell off maybe 50 miles after installation. Should I replace the entire crank, just the arm, or repair the thread?
Why can my keyboard only digest 6 keypresses at a time?
Overlapping String-Blocks
Is it safe to change the harddrive power feature so that it never turns off?
Is it a bad idea to to run 24 tap and shock lands in standard
Why didn't Voldemort recognize that Dumbledore was affected by his curse?
Why was this person allowed to become Grand Maester?
How to safely destroy (a large quantity of) valid checks?
Does the new finding on "reversing a quantum jump mid-flight" rule out any interpretations of QM?
A map of non-pathological topology?
Someone whose aspirations exceed abilities or means
Which languages would be most useful in Europe at the end of the 19th century?
Is it possible to have a wealthy country without a middle class?
Wooden cooking layout
What is the maximum number of net attacks that one can make in a round?
Entire circuit dead after GFCI outlet
Traversing Oceania: A Cryptic Journey
Override PlaceOrder and change Grand Total
Get Order Info at the ordering moment and send out invoiceMagento update quote item change row totalHow to get order Grand Total from information about order's items (products)?Magento 2.1: How to handle custom payment grand total mismatch upon return to the merchant ?siteMagento 2 - Change maximum order amountMagento 2: How can I update tax and total programmatically on checkout?Magento2 - Override Template order summary in sales email orderCorrect admin menu location for an “Order Attributes” extension for Magento 2Magento 2 : How to change the quantity of items in the checkout?How to create duplicate new quote from old order quote Magento 1.7?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am modifying the placeOrder function of the QuoteManagement class, based on some information I found through searches, I was able to change the method so that an order is generated for each seller, but the values are kept the same, ie I get the value total of all items and not just the value of the already separated items. Can someone tell me what place or what should I do so that the total amount is separated according to the items of each order?
PlaceOrder
public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
$quote = $this->quoteRepository->getActive($cartId);
$paymentMethodString = $quote->getPayment()->getMethod(); // edit 19.10.17
// get data from addresses and remove ids
$billingAddress = $quote->getBillingAddress()->getData();
$shippingAddress = $quote->getShippingAddress()->getData();
unset($billingAddress['id']);
unset($billingAddress['quote_id']);
unset($shippingAddress['id']);
unset($shippingAddress['quote_id']);
$itemsPerVendor = [];
foreach($quote->getAllItems() as $item)
// I don't know how do you keep track of your product vendor, use this as reference only
$product_id = $item->getProduct()->getId();
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->create('MagentoCatalogModelProduct')->load($product_id);
$itemsPerVendor[$product->getSellerId()][] = $item;
foreach($itemsPerVendor as $vendor => $items)
// init Quote Split
$quoteSplit = $this->quoteFactory->create();
$quoteSplit->setStoreId($quote->getStoreId());
$quoteSplit->setCustomer($quote->getCustomer());
$quoteSplit->setCustomerIsGuest($quote->getCustomerIsGuest());
if ($quote->getCheckoutMethod() === self::METHOD_GUEST)
$quoteSplit->setCustomerEmail($quote->getBillingAddress()->getEmail());
$quoteSplit->setCustomerGroupId(MagentoCustomerApiDataGroupInterface::NOT_LOGGED_IN_ID);
// save quoteSplit in order to have a quote id for item
$this->quoteRepository->save($quoteSplit);
$subtotal = 0;
foreach ($items as $item)
// add item
$item->setId(null); // init item id for force to be added to quoteSplit collection
$quoteSplit->addItem($item);
// set addresses
$quoteSplit->getBillingAddress()->setData($billingAddress);
$quoteSplit->getShippingAddress()->setData($shippingAddress);
// recollect totals into the quote
$quoteSplit->setTotalsCollectedFlag(false)->collectTotals();
// set payment method // edit 19.10.17
$quoteSplit->getPayment()->setMethod($paymentMethodString);
if ($paymentMethod)
$quoteSplit->getPayment()->setQuote($quoteSplit);
$data = $paymentMethod->getData();
$quoteSplit->getPayment()->importData($data);
$this->quoteRepository->save($quoteSplit);
// dispatch this event as Magento standard once per each quote split
$this->eventManager->dispatch('checkout_submit_before', ['quote' => $quoteSplit]);
$order = $this->submit($quoteSplit);
$orders[] = $order;
if (null == $order)
throw new LocalizedException(
__('An error occurred on the server. Please try to place the order again.')
);
// disable origin quote
$quote->setIsActive(false);
$this->quoteRepository->save($quote); // edit 19.10.17
$this->checkoutSession->setLastQuoteId($quoteSplit->getId());
$this->checkoutSession->setLastSuccessQuoteId($quoteSplit->getId());
$this->checkoutSession->setLastOrderId($order->getId());
$this->checkoutSession->setLastRealOrderId($order->getIncrementId());
$this->checkoutSession->setLastOrderStatus($order->getStatus());
$this->eventManager->dispatch('checkout_submit_all_after', ['orders' => $orders, 'quote' => $quote]);
/**
* the API declaration and interface describe this function returning int, you can't return an array.
* in order to do that you will have to create a new end point for that.
*/
return;
How can I set grand total and subtotal of each order after order split?
magento2 orders quote grand-total
add a comment |
I am modifying the placeOrder function of the QuoteManagement class, based on some information I found through searches, I was able to change the method so that an order is generated for each seller, but the values are kept the same, ie I get the value total of all items and not just the value of the already separated items. Can someone tell me what place or what should I do so that the total amount is separated according to the items of each order?
PlaceOrder
public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
$quote = $this->quoteRepository->getActive($cartId);
$paymentMethodString = $quote->getPayment()->getMethod(); // edit 19.10.17
// get data from addresses and remove ids
$billingAddress = $quote->getBillingAddress()->getData();
$shippingAddress = $quote->getShippingAddress()->getData();
unset($billingAddress['id']);
unset($billingAddress['quote_id']);
unset($shippingAddress['id']);
unset($shippingAddress['quote_id']);
$itemsPerVendor = [];
foreach($quote->getAllItems() as $item)
// I don't know how do you keep track of your product vendor, use this as reference only
$product_id = $item->getProduct()->getId();
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->create('MagentoCatalogModelProduct')->load($product_id);
$itemsPerVendor[$product->getSellerId()][] = $item;
foreach($itemsPerVendor as $vendor => $items)
// init Quote Split
$quoteSplit = $this->quoteFactory->create();
$quoteSplit->setStoreId($quote->getStoreId());
$quoteSplit->setCustomer($quote->getCustomer());
$quoteSplit->setCustomerIsGuest($quote->getCustomerIsGuest());
if ($quote->getCheckoutMethod() === self::METHOD_GUEST)
$quoteSplit->setCustomerEmail($quote->getBillingAddress()->getEmail());
$quoteSplit->setCustomerGroupId(MagentoCustomerApiDataGroupInterface::NOT_LOGGED_IN_ID);
// save quoteSplit in order to have a quote id for item
$this->quoteRepository->save($quoteSplit);
$subtotal = 0;
foreach ($items as $item)
// add item
$item->setId(null); // init item id for force to be added to quoteSplit collection
$quoteSplit->addItem($item);
// set addresses
$quoteSplit->getBillingAddress()->setData($billingAddress);
$quoteSplit->getShippingAddress()->setData($shippingAddress);
// recollect totals into the quote
$quoteSplit->setTotalsCollectedFlag(false)->collectTotals();
// set payment method // edit 19.10.17
$quoteSplit->getPayment()->setMethod($paymentMethodString);
if ($paymentMethod)
$quoteSplit->getPayment()->setQuote($quoteSplit);
$data = $paymentMethod->getData();
$quoteSplit->getPayment()->importData($data);
$this->quoteRepository->save($quoteSplit);
// dispatch this event as Magento standard once per each quote split
$this->eventManager->dispatch('checkout_submit_before', ['quote' => $quoteSplit]);
$order = $this->submit($quoteSplit);
$orders[] = $order;
if (null == $order)
throw new LocalizedException(
__('An error occurred on the server. Please try to place the order again.')
);
// disable origin quote
$quote->setIsActive(false);
$this->quoteRepository->save($quote); // edit 19.10.17
$this->checkoutSession->setLastQuoteId($quoteSplit->getId());
$this->checkoutSession->setLastSuccessQuoteId($quoteSplit->getId());
$this->checkoutSession->setLastOrderId($order->getId());
$this->checkoutSession->setLastRealOrderId($order->getIncrementId());
$this->checkoutSession->setLastOrderStatus($order->getStatus());
$this->eventManager->dispatch('checkout_submit_all_after', ['orders' => $orders, 'quote' => $quote]);
/**
* the API declaration and interface describe this function returning int, you can't return an array.
* in order to do that you will have to create a new end point for that.
*/
return;
How can I set grand total and subtotal of each order after order split?
magento2 orders quote grand-total
add a comment |
I am modifying the placeOrder function of the QuoteManagement class, based on some information I found through searches, I was able to change the method so that an order is generated for each seller, but the values are kept the same, ie I get the value total of all items and not just the value of the already separated items. Can someone tell me what place or what should I do so that the total amount is separated according to the items of each order?
PlaceOrder
public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
$quote = $this->quoteRepository->getActive($cartId);
$paymentMethodString = $quote->getPayment()->getMethod(); // edit 19.10.17
// get data from addresses and remove ids
$billingAddress = $quote->getBillingAddress()->getData();
$shippingAddress = $quote->getShippingAddress()->getData();
unset($billingAddress['id']);
unset($billingAddress['quote_id']);
unset($shippingAddress['id']);
unset($shippingAddress['quote_id']);
$itemsPerVendor = [];
foreach($quote->getAllItems() as $item)
// I don't know how do you keep track of your product vendor, use this as reference only
$product_id = $item->getProduct()->getId();
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->create('MagentoCatalogModelProduct')->load($product_id);
$itemsPerVendor[$product->getSellerId()][] = $item;
foreach($itemsPerVendor as $vendor => $items)
// init Quote Split
$quoteSplit = $this->quoteFactory->create();
$quoteSplit->setStoreId($quote->getStoreId());
$quoteSplit->setCustomer($quote->getCustomer());
$quoteSplit->setCustomerIsGuest($quote->getCustomerIsGuest());
if ($quote->getCheckoutMethod() === self::METHOD_GUEST)
$quoteSplit->setCustomerEmail($quote->getBillingAddress()->getEmail());
$quoteSplit->setCustomerGroupId(MagentoCustomerApiDataGroupInterface::NOT_LOGGED_IN_ID);
// save quoteSplit in order to have a quote id for item
$this->quoteRepository->save($quoteSplit);
$subtotal = 0;
foreach ($items as $item)
// add item
$item->setId(null); // init item id for force to be added to quoteSplit collection
$quoteSplit->addItem($item);
// set addresses
$quoteSplit->getBillingAddress()->setData($billingAddress);
$quoteSplit->getShippingAddress()->setData($shippingAddress);
// recollect totals into the quote
$quoteSplit->setTotalsCollectedFlag(false)->collectTotals();
// set payment method // edit 19.10.17
$quoteSplit->getPayment()->setMethod($paymentMethodString);
if ($paymentMethod)
$quoteSplit->getPayment()->setQuote($quoteSplit);
$data = $paymentMethod->getData();
$quoteSplit->getPayment()->importData($data);
$this->quoteRepository->save($quoteSplit);
// dispatch this event as Magento standard once per each quote split
$this->eventManager->dispatch('checkout_submit_before', ['quote' => $quoteSplit]);
$order = $this->submit($quoteSplit);
$orders[] = $order;
if (null == $order)
throw new LocalizedException(
__('An error occurred on the server. Please try to place the order again.')
);
// disable origin quote
$quote->setIsActive(false);
$this->quoteRepository->save($quote); // edit 19.10.17
$this->checkoutSession->setLastQuoteId($quoteSplit->getId());
$this->checkoutSession->setLastSuccessQuoteId($quoteSplit->getId());
$this->checkoutSession->setLastOrderId($order->getId());
$this->checkoutSession->setLastRealOrderId($order->getIncrementId());
$this->checkoutSession->setLastOrderStatus($order->getStatus());
$this->eventManager->dispatch('checkout_submit_all_after', ['orders' => $orders, 'quote' => $quote]);
/**
* the API declaration and interface describe this function returning int, you can't return an array.
* in order to do that you will have to create a new end point for that.
*/
return;
How can I set grand total and subtotal of each order after order split?
magento2 orders quote grand-total
I am modifying the placeOrder function of the QuoteManagement class, based on some information I found through searches, I was able to change the method so that an order is generated for each seller, but the values are kept the same, ie I get the value total of all items and not just the value of the already separated items. Can someone tell me what place or what should I do so that the total amount is separated according to the items of each order?
PlaceOrder
public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
$quote = $this->quoteRepository->getActive($cartId);
$paymentMethodString = $quote->getPayment()->getMethod(); // edit 19.10.17
// get data from addresses and remove ids
$billingAddress = $quote->getBillingAddress()->getData();
$shippingAddress = $quote->getShippingAddress()->getData();
unset($billingAddress['id']);
unset($billingAddress['quote_id']);
unset($shippingAddress['id']);
unset($shippingAddress['quote_id']);
$itemsPerVendor = [];
foreach($quote->getAllItems() as $item)
// I don't know how do you keep track of your product vendor, use this as reference only
$product_id = $item->getProduct()->getId();
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->create('MagentoCatalogModelProduct')->load($product_id);
$itemsPerVendor[$product->getSellerId()][] = $item;
foreach($itemsPerVendor as $vendor => $items)
// init Quote Split
$quoteSplit = $this->quoteFactory->create();
$quoteSplit->setStoreId($quote->getStoreId());
$quoteSplit->setCustomer($quote->getCustomer());
$quoteSplit->setCustomerIsGuest($quote->getCustomerIsGuest());
if ($quote->getCheckoutMethod() === self::METHOD_GUEST)
$quoteSplit->setCustomerEmail($quote->getBillingAddress()->getEmail());
$quoteSplit->setCustomerGroupId(MagentoCustomerApiDataGroupInterface::NOT_LOGGED_IN_ID);
// save quoteSplit in order to have a quote id for item
$this->quoteRepository->save($quoteSplit);
$subtotal = 0;
foreach ($items as $item)
// add item
$item->setId(null); // init item id for force to be added to quoteSplit collection
$quoteSplit->addItem($item);
// set addresses
$quoteSplit->getBillingAddress()->setData($billingAddress);
$quoteSplit->getShippingAddress()->setData($shippingAddress);
// recollect totals into the quote
$quoteSplit->setTotalsCollectedFlag(false)->collectTotals();
// set payment method // edit 19.10.17
$quoteSplit->getPayment()->setMethod($paymentMethodString);
if ($paymentMethod)
$quoteSplit->getPayment()->setQuote($quoteSplit);
$data = $paymentMethod->getData();
$quoteSplit->getPayment()->importData($data);
$this->quoteRepository->save($quoteSplit);
// dispatch this event as Magento standard once per each quote split
$this->eventManager->dispatch('checkout_submit_before', ['quote' => $quoteSplit]);
$order = $this->submit($quoteSplit);
$orders[] = $order;
if (null == $order)
throw new LocalizedException(
__('An error occurred on the server. Please try to place the order again.')
);
// disable origin quote
$quote->setIsActive(false);
$this->quoteRepository->save($quote); // edit 19.10.17
$this->checkoutSession->setLastQuoteId($quoteSplit->getId());
$this->checkoutSession->setLastSuccessQuoteId($quoteSplit->getId());
$this->checkoutSession->setLastOrderId($order->getId());
$this->checkoutSession->setLastRealOrderId($order->getIncrementId());
$this->checkoutSession->setLastOrderStatus($order->getStatus());
$this->eventManager->dispatch('checkout_submit_all_after', ['orders' => $orders, 'quote' => $quote]);
/**
* the API declaration and interface describe this function returning int, you can't return an array.
* in order to do that you will have to create a new end point for that.
*/
return;
How can I set grand total and subtotal of each order after order split?
magento2 orders quote grand-total
magento2 orders quote grand-total
edited Jun 1 at 13:18
Luis Faconi
asked Jun 1 at 13:04
Luis FaconiLuis Faconi
264
264
add a comment |
add a comment |
0
active
oldest
votes
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%2f276967%2foverride-placeorder-and-change-grand-total%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
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%2f276967%2foverride-placeorder-and-change-grand-total%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