Can't set shipping method on order created programmatically“Please specify a shipping method” when...

Does casting Light, or a similar spell, have any effect when the caster is swallowed by a monster?

Why do I get two different answers for this counting problem?

I'm flying to France today and my passport expires in less than 2 months

What is the word for reserving something for yourself before others do?

Can a rocket refuel on Mars from water?

Infinite Abelian subgroup of infinite non Abelian group example

How do I find out when a node was added to an availability group?

Plain language with long required phrases

Cronab fails because shell path not found

Took a trip to a parallel universe, need help deciphering

Were any external disk drives stacked vertically?

Would Slavery Reparations be considered Bills of Attainder and hence Illegal?

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

Anagram holiday

Why does Optional.map make this assignment work?

Is the Joker left-handed?

Is it possible to create light that imparts a greater proportion of its energy as momentum rather than heat?

Etiquette around loan refinance - decision is going to cost first broker a lot of money

Why can't we play rap on piano?

How could indestructible materials be used in power generation?

I would say: "You are another teacher", but she is a woman and I am a man

What is the intuition behind short exact sequences of groups; in particular, what is the intuition behind group extensions?

Arrow those variables!

How do I write bicross product symbols in latex?



Can't set shipping method on order created programmatically


“Please specify a shipping method” when programmatically creating an orderCustom cron causing one page checkout deadlocksSet Shipping Method in CartShipping method only avialable for manual order creation 1.9Create invoice and shipment in magento via cron based on store view and order ageCreate an order on API callMagento Order Mangement Confusion? No invoice automatically created?PayPal Checkout and Account Registration ConflictM1 CE, paypal exception “PayPal NVP gateway errors”how to fetch order number, payment method and customer name according to invoice number in admin panel grid?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I have been searching for an answer on the web, but have tried all the solutions I have found and nothing seems to work.



The order adds fine, but in the admin panel is shows "No shipping information available".



When I go through the cart, then it shows "Free Shipping".



Any ideas on how to set the shipping method on the order?



           //Product to add to the order
$product = Mage::getSingleton('catalog/product')->load($productId);

//Previous order to copy from
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
$converter = Mage::getModel('sales/convert_order');
$quote = $converter->toQuote($order);

$quote->setBillingAddress($converter->addressToQuoteAddress($order->getBillingAddress()));
$quote->setShippingAddress($converter->addressToQuoteAddress($order->getShippingAddress()));
$quote->getShippingAddress()->setShippingMethod("tablerate_bestway");
$shippingAddress = $quote->getShippingAddress();
$shippingAddress->setFreeShipping( true )
->setCollectShippingRates(true)->collectShippingRates()
->setShippingMethod(‘tablerate_bestway’)
->setPaymentMethod(‘checkmo’);

$quote->setStore($order->getStore());
$quote->setCustomer($customer);
$converter->paymentToQuotePayment($order->getPayment(), $quote->getPayment());




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


$newOrder = Mage::getModel('sales/order');

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

$newOrder->setPayment($payment);
$newOrder->setBillingAddress($convert->addressToOrderAddress($quote->getBillingAddress()));
$newOrder->setShippingAddress($convert->addressToOrderAddress($quote->getShippingAddress()))->setShipping_Method('tablerate_bestway');
$newOrder->getShippingAddress()->setFreeShipping(true);
$newOrder->setShippingMethod('tablerate_bestway');
$newOrder->setCustomerId($customer->getId());
$newOrder->setCustomerFirstname($customer->getFirstname());
$newOrder->setCustomerLastname($customer->getLastname());
$newOrder->setCustomerEmail($customer->getEmail());

$newOrder->setState(Mage_Sales_Model_Order::STATE_PROCESSING,true);
$order->setWeight($product->getWeight());

$newOrder->setSubtotal($product->getPrice())
->setBaseSubtotal($product->getPrice())
->setGrandTotal($product->getPrice())
->setBaseGrandTotal($product->getPrice());


$message = 'Generated Order';
$newOrder->addStatusToHistory($newOrder->getStatus(), $message);

$orderItem = Mage::getModel('sales/order_item')
->setStoreId($newOrder->getStore()->getStoreId())
->setQuoteItemId(NULL)
->setQuoteParentItemId(NULL)
->setProductId($product->getId())
->setProductType($product->getTypeId())
->setQtyBackordered(NULL)
->setTotalQtyOrdered(1)
->setQtyOrdered(1)
->setWeight($product->getWeight())
->setIsVirtual(0)
->setIsQtyDecimal(0)
->setQtyInvoiced(1)
->setName($product->getName()." Generated")
->setSku($product->getSku())
->setPrice($product->getPrice())
->setBasePrice($product->getPrice())
->setBaseOriginalPrice($product->getPrice())
->setOriginalPrice($product->getPrice())
->setRowTotal($product->getPrice())
->setBaseRowTotal($product->getPrice())
->setOrder($newOrder)
->setProductOptions($savedOptions);

$newOrder->addItem($orderItem);

$newOrder->save();

$invoice = Mage::getModel('sales/service_order', $newOrder)->prepareInvoice();
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::STATE_PAID);
$invoice->register();
$invoice->setAmount($grandtotal);
$invoice->pay()->save();
$transactionSave = Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($newOrder);

$newOrder->save();
$transactionSave->save();

$payment->pay($invoice);









share|improve this question














bumped to the homepage by Community 19 mins ago


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






















    1















    I have been searching for an answer on the web, but have tried all the solutions I have found and nothing seems to work.



    The order adds fine, but in the admin panel is shows "No shipping information available".



    When I go through the cart, then it shows "Free Shipping".



    Any ideas on how to set the shipping method on the order?



               //Product to add to the order
    $product = Mage::getSingleton('catalog/product')->load($productId);

    //Previous order to copy from
    $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
    $converter = Mage::getModel('sales/convert_order');
    $quote = $converter->toQuote($order);

    $quote->setBillingAddress($converter->addressToQuoteAddress($order->getBillingAddress()));
    $quote->setShippingAddress($converter->addressToQuoteAddress($order->getShippingAddress()));
    $quote->getShippingAddress()->setShippingMethod("tablerate_bestway");
    $shippingAddress = $quote->getShippingAddress();
    $shippingAddress->setFreeShipping( true )
    ->setCollectShippingRates(true)->collectShippingRates()
    ->setShippingMethod(‘tablerate_bestway’)
    ->setPaymentMethod(‘checkmo’);

    $quote->setStore($order->getStore());
    $quote->setCustomer($customer);
    $converter->paymentToQuotePayment($order->getPayment(), $quote->getPayment());




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


    $newOrder = Mage::getModel('sales/order');

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

    $newOrder->setPayment($payment);
    $newOrder->setBillingAddress($convert->addressToOrderAddress($quote->getBillingAddress()));
    $newOrder->setShippingAddress($convert->addressToOrderAddress($quote->getShippingAddress()))->setShipping_Method('tablerate_bestway');
    $newOrder->getShippingAddress()->setFreeShipping(true);
    $newOrder->setShippingMethod('tablerate_bestway');
    $newOrder->setCustomerId($customer->getId());
    $newOrder->setCustomerFirstname($customer->getFirstname());
    $newOrder->setCustomerLastname($customer->getLastname());
    $newOrder->setCustomerEmail($customer->getEmail());

    $newOrder->setState(Mage_Sales_Model_Order::STATE_PROCESSING,true);
    $order->setWeight($product->getWeight());

    $newOrder->setSubtotal($product->getPrice())
    ->setBaseSubtotal($product->getPrice())
    ->setGrandTotal($product->getPrice())
    ->setBaseGrandTotal($product->getPrice());


    $message = 'Generated Order';
    $newOrder->addStatusToHistory($newOrder->getStatus(), $message);

    $orderItem = Mage::getModel('sales/order_item')
    ->setStoreId($newOrder->getStore()->getStoreId())
    ->setQuoteItemId(NULL)
    ->setQuoteParentItemId(NULL)
    ->setProductId($product->getId())
    ->setProductType($product->getTypeId())
    ->setQtyBackordered(NULL)
    ->setTotalQtyOrdered(1)
    ->setQtyOrdered(1)
    ->setWeight($product->getWeight())
    ->setIsVirtual(0)
    ->setIsQtyDecimal(0)
    ->setQtyInvoiced(1)
    ->setName($product->getName()." Generated")
    ->setSku($product->getSku())
    ->setPrice($product->getPrice())
    ->setBasePrice($product->getPrice())
    ->setBaseOriginalPrice($product->getPrice())
    ->setOriginalPrice($product->getPrice())
    ->setRowTotal($product->getPrice())
    ->setBaseRowTotal($product->getPrice())
    ->setOrder($newOrder)
    ->setProductOptions($savedOptions);

    $newOrder->addItem($orderItem);

    $newOrder->save();

    $invoice = Mage::getModel('sales/service_order', $newOrder)->prepareInvoice();
    $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::STATE_PAID);
    $invoice->register();
    $invoice->setAmount($grandtotal);
    $invoice->pay()->save();
    $transactionSave = Mage::getModel('core/resource_transaction')
    ->addObject($invoice)
    ->addObject($newOrder);

    $newOrder->save();
    $transactionSave->save();

    $payment->pay($invoice);









    share|improve this question














    bumped to the homepage by Community 19 mins ago


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


















      1












      1








      1








      I have been searching for an answer on the web, but have tried all the solutions I have found and nothing seems to work.



      The order adds fine, but in the admin panel is shows "No shipping information available".



      When I go through the cart, then it shows "Free Shipping".



      Any ideas on how to set the shipping method on the order?



                 //Product to add to the order
      $product = Mage::getSingleton('catalog/product')->load($productId);

      //Previous order to copy from
      $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
      $converter = Mage::getModel('sales/convert_order');
      $quote = $converter->toQuote($order);

      $quote->setBillingAddress($converter->addressToQuoteAddress($order->getBillingAddress()));
      $quote->setShippingAddress($converter->addressToQuoteAddress($order->getShippingAddress()));
      $quote->getShippingAddress()->setShippingMethod("tablerate_bestway");
      $shippingAddress = $quote->getShippingAddress();
      $shippingAddress->setFreeShipping( true )
      ->setCollectShippingRates(true)->collectShippingRates()
      ->setShippingMethod(‘tablerate_bestway’)
      ->setPaymentMethod(‘checkmo’);

      $quote->setStore($order->getStore());
      $quote->setCustomer($customer);
      $converter->paymentToQuotePayment($order->getPayment(), $quote->getPayment());




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


      $newOrder = Mage::getModel('sales/order');

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

      $newOrder->setPayment($payment);
      $newOrder->setBillingAddress($convert->addressToOrderAddress($quote->getBillingAddress()));
      $newOrder->setShippingAddress($convert->addressToOrderAddress($quote->getShippingAddress()))->setShipping_Method('tablerate_bestway');
      $newOrder->getShippingAddress()->setFreeShipping(true);
      $newOrder->setShippingMethod('tablerate_bestway');
      $newOrder->setCustomerId($customer->getId());
      $newOrder->setCustomerFirstname($customer->getFirstname());
      $newOrder->setCustomerLastname($customer->getLastname());
      $newOrder->setCustomerEmail($customer->getEmail());

      $newOrder->setState(Mage_Sales_Model_Order::STATE_PROCESSING,true);
      $order->setWeight($product->getWeight());

      $newOrder->setSubtotal($product->getPrice())
      ->setBaseSubtotal($product->getPrice())
      ->setGrandTotal($product->getPrice())
      ->setBaseGrandTotal($product->getPrice());


      $message = 'Generated Order';
      $newOrder->addStatusToHistory($newOrder->getStatus(), $message);

      $orderItem = Mage::getModel('sales/order_item')
      ->setStoreId($newOrder->getStore()->getStoreId())
      ->setQuoteItemId(NULL)
      ->setQuoteParentItemId(NULL)
      ->setProductId($product->getId())
      ->setProductType($product->getTypeId())
      ->setQtyBackordered(NULL)
      ->setTotalQtyOrdered(1)
      ->setQtyOrdered(1)
      ->setWeight($product->getWeight())
      ->setIsVirtual(0)
      ->setIsQtyDecimal(0)
      ->setQtyInvoiced(1)
      ->setName($product->getName()." Generated")
      ->setSku($product->getSku())
      ->setPrice($product->getPrice())
      ->setBasePrice($product->getPrice())
      ->setBaseOriginalPrice($product->getPrice())
      ->setOriginalPrice($product->getPrice())
      ->setRowTotal($product->getPrice())
      ->setBaseRowTotal($product->getPrice())
      ->setOrder($newOrder)
      ->setProductOptions($savedOptions);

      $newOrder->addItem($orderItem);

      $newOrder->save();

      $invoice = Mage::getModel('sales/service_order', $newOrder)->prepareInvoice();
      $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::STATE_PAID);
      $invoice->register();
      $invoice->setAmount($grandtotal);
      $invoice->pay()->save();
      $transactionSave = Mage::getModel('core/resource_transaction')
      ->addObject($invoice)
      ->addObject($newOrder);

      $newOrder->save();
      $transactionSave->save();

      $payment->pay($invoice);









      share|improve this question














      I have been searching for an answer on the web, but have tried all the solutions I have found and nothing seems to work.



      The order adds fine, but in the admin panel is shows "No shipping information available".



      When I go through the cart, then it shows "Free Shipping".



      Any ideas on how to set the shipping method on the order?



                 //Product to add to the order
      $product = Mage::getSingleton('catalog/product')->load($productId);

      //Previous order to copy from
      $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
      $converter = Mage::getModel('sales/convert_order');
      $quote = $converter->toQuote($order);

      $quote->setBillingAddress($converter->addressToQuoteAddress($order->getBillingAddress()));
      $quote->setShippingAddress($converter->addressToQuoteAddress($order->getShippingAddress()));
      $quote->getShippingAddress()->setShippingMethod("tablerate_bestway");
      $shippingAddress = $quote->getShippingAddress();
      $shippingAddress->setFreeShipping( true )
      ->setCollectShippingRates(true)->collectShippingRates()
      ->setShippingMethod(‘tablerate_bestway’)
      ->setPaymentMethod(‘checkmo’);

      $quote->setStore($order->getStore());
      $quote->setCustomer($customer);
      $converter->paymentToQuotePayment($order->getPayment(), $quote->getPayment());




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


      $newOrder = Mage::getModel('sales/order');

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

      $newOrder->setPayment($payment);
      $newOrder->setBillingAddress($convert->addressToOrderAddress($quote->getBillingAddress()));
      $newOrder->setShippingAddress($convert->addressToOrderAddress($quote->getShippingAddress()))->setShipping_Method('tablerate_bestway');
      $newOrder->getShippingAddress()->setFreeShipping(true);
      $newOrder->setShippingMethod('tablerate_bestway');
      $newOrder->setCustomerId($customer->getId());
      $newOrder->setCustomerFirstname($customer->getFirstname());
      $newOrder->setCustomerLastname($customer->getLastname());
      $newOrder->setCustomerEmail($customer->getEmail());

      $newOrder->setState(Mage_Sales_Model_Order::STATE_PROCESSING,true);
      $order->setWeight($product->getWeight());

      $newOrder->setSubtotal($product->getPrice())
      ->setBaseSubtotal($product->getPrice())
      ->setGrandTotal($product->getPrice())
      ->setBaseGrandTotal($product->getPrice());


      $message = 'Generated Order';
      $newOrder->addStatusToHistory($newOrder->getStatus(), $message);

      $orderItem = Mage::getModel('sales/order_item')
      ->setStoreId($newOrder->getStore()->getStoreId())
      ->setQuoteItemId(NULL)
      ->setQuoteParentItemId(NULL)
      ->setProductId($product->getId())
      ->setProductType($product->getTypeId())
      ->setQtyBackordered(NULL)
      ->setTotalQtyOrdered(1)
      ->setQtyOrdered(1)
      ->setWeight($product->getWeight())
      ->setIsVirtual(0)
      ->setIsQtyDecimal(0)
      ->setQtyInvoiced(1)
      ->setName($product->getName()." Generated")
      ->setSku($product->getSku())
      ->setPrice($product->getPrice())
      ->setBasePrice($product->getPrice())
      ->setBaseOriginalPrice($product->getPrice())
      ->setOriginalPrice($product->getPrice())
      ->setRowTotal($product->getPrice())
      ->setBaseRowTotal($product->getPrice())
      ->setOrder($newOrder)
      ->setProductOptions($savedOptions);

      $newOrder->addItem($orderItem);

      $newOrder->save();

      $invoice = Mage::getModel('sales/service_order', $newOrder)->prepareInvoice();
      $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::STATE_PAID);
      $invoice->register();
      $invoice->setAmount($grandtotal);
      $invoice->pay()->save();
      $transactionSave = Mage::getModel('core/resource_transaction')
      ->addObject($invoice)
      ->addObject($newOrder);

      $newOrder->save();
      $transactionSave->save();

      $payment->pay($invoice);






      magento-1.9 orders shipping-methods






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 10 '16 at 3:24









      user1579943user1579943

      236




      236





      bumped to the homepage by Community 19 mins ago


      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 19 mins ago


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
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Please use this



          $order->setShippingAddress($shippingAddress)
          ->setShipping_method(<Code>)
          ->setShippingDescription(<Title>);


          For Ex. UPS we set as



          $order->setShippingAddress($shippingAddress)
          ->setShipping_method('ups')
          ->setShippingDescription('UPS');





          share|improve this answer
























            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%2f149726%2fcant-set-shipping-method-on-order-created-programmatically%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Please use this



            $order->setShippingAddress($shippingAddress)
            ->setShipping_method(<Code>)
            ->setShippingDescription(<Title>);


            For Ex. UPS we set as



            $order->setShippingAddress($shippingAddress)
            ->setShipping_method('ups')
            ->setShippingDescription('UPS');





            share|improve this answer




























              0














              Please use this



              $order->setShippingAddress($shippingAddress)
              ->setShipping_method(<Code>)
              ->setShippingDescription(<Title>);


              For Ex. UPS we set as



              $order->setShippingAddress($shippingAddress)
              ->setShipping_method('ups')
              ->setShippingDescription('UPS');





              share|improve this answer


























                0












                0








                0







                Please use this



                $order->setShippingAddress($shippingAddress)
                ->setShipping_method(<Code>)
                ->setShippingDescription(<Title>);


                For Ex. UPS we set as



                $order->setShippingAddress($shippingAddress)
                ->setShipping_method('ups')
                ->setShippingDescription('UPS');





                share|improve this answer













                Please use this



                $order->setShippingAddress($shippingAddress)
                ->setShipping_method(<Code>)
                ->setShippingDescription(<Title>);


                For Ex. UPS we set as



                $order->setShippingAddress($shippingAddress)
                ->setShipping_method('ups')
                ->setShippingDescription('UPS');






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jun 20 '18 at 14:07









                DivyarajsinhDivyarajsinh

                409212




                409212






























                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f149726%2fcant-set-shipping-method-on-order-created-programmatically%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

                    迭戈·戈丁...

                    A phrase ”follow into" in a context The 2019 Stack Overflow Developer Survey Results Are...

                    1960s short story making fun of James Bond-style spy fiction The 2019 Stack Overflow Developer...