Ошибка сервера не позволила разместить ваш заказ. Пожалуйста, попробуйте сделать заказ еще раз - PullRequest
0 голосов
/ 12 февраля 2020

Я создал модуль для создания быстрого заказа, чтобы клиент мог разместить там заказ без регистрации или входа в систему. Я получаю 5 полей от клиентов, чтобы обработать их заказ и он работает нормально. Я отладил приведенный ниже код и он работает нормально, за исключением $order_id = $cartManagementInterface->placeOrder($cart->getId());, в этой строке кода появляется ошибка Ошибка сервера не позволила разместить ваш заказ. Пожалуйста, попробуйте сделать заказ еще раз. Я не знаю проблему сейчас и ищу быстрое решение. когда я пытаюсь проверить журнал, я обнаружил следующую ошибку {"0": "Ошибка сервера не позволила разместить ваш заказ. Пожалуйста, попробуйте разместить свой заказ снова.", "1": "#1 Magento\Quote\Model\QuoteManagement\Interceptor->___callParent('placeOrder', array(11804, NULL)) called at [vendor/magento/framework/Interception/Interceptor.php:138]\n#2 Magento\Quote\Model\QuoteManagement\Interceptor->Magento\Framework\Interception\{closure}(11804, NULL) called at [vendor/magento/module-braintree/Plugin/OrderCancellation.php:63]\n#3 Magento\Braintree\Plugin\OrderCancellation->aroundPlaceOrder(&Magento\Quote\Model\QuoteManagement\Interceptor#0000000068771282000000001567ed28#, &Closure#0000000068771726000000001567ed28#, 11804) called at [vendor/magento/framework/Interception/Interceptor.php:135]\n#4 Magento\Quote\Model\QuoteManagement\Interceptor->Magento\Framework\Interception\{closure}(11804) called at [vendor/magento/framework/Interception/Interceptor.php:153]\n#5 Magento\Quote\Model\QuoteManagement\Interceptor->___callPlugins('placeOrder', array(11804), NULL) called at [generated/code/Magento/Quote/Model/QuoteManagement/Interceptor.php:26]</strong></p> <code>namespace QuickOrder\QuickBuy\Controller\Index; use Magento\Framework\App\Bootstrap; class CustomOrders extends \Magento\Framework\App\Action\Action { protected $_pageFactory; protected $_helper; //protected $_data; public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $pageFactory, \QuickOrder\QuickBuy\Helper\Data $helper) { $this->_pageFactory = $pageFactory; $this->_helper = $helper; return parent::__construct($context); } public function execute() { $email = "demo@demo.com"; $fname = "fname"; $lname = "lname"; $password = "password"; $product_id = 1036; $object = \Magento\Framework\App\ObjectManager::getInstance(); $storeManager = $object->get('Magento\Store\Model\StoreManagerInterface'); $customerFactory = $object->get('Magento\Customer\Model\CustomerFactory'); $cartManagementInterface = $object->get('Magento\Quote\Api\CartManagementInterface'); $cartRepositoryInterface = $object->get('Magento\Quote\Api\CartRepositoryInterface'); $customerRepository= $object->get('Magento\Customer\Api\CustomerRepositoryInterface'); $shippingRate= $object->get('Magento\Quote\Model\Quote\Address\Rate'); $productFactory=$object->get('Magento\Catalog\Model\ProductFactory'); $store = $storeManager->getStore(); $websiteId = $storeManager->getStore()->getWebsiteId(); $customer=$customerFactory->create(); $customer->setWebsiteId($websiteId); $customer->loadByEmail($email); if(!$customer->getEntityId()){ $customer->setWebsiteId($websiteId) ->setStore($store) ->setFirstname($fname) ->setLastname($lname) ->setEmail($email) ->setPassword($password); $customer->save(); } $cart_id = $cartManagementInterface->createEmptyCart(); $cart = $cartRepositoryInterface->get($cart_id); $cart->setStore($store); $customer= $customerRepository->getById($customer->getEntityId()); $cart->setCurrency(); $cart->assignCustomer($customer); $product = $productFactory->create()->load($product_id); $cart->addProduct($product,1); $orderData =[ 'currency_id' => 'PKR', 'email' => 'test.magecomp@gmail.com', //buyer email id 'shipping_address' =>[ 'firstname' => 'John', //address Details 'lastname' => 'Deo', 'street' => 'Main Street', 'city' => 'Lahore', 'country_id' => 'PK', 'region' => 'Punjab', 'postcode' => '85001', 'telephone' => '823322565', 'fax' => '3245845623', 'shipping_method' => 'flatrate', 'save_in_address_book' => 1 ], 'items'=> [ //array of product which order you want to create ['product_id'=>'1036','price'=> '899','qty'=>2] ] ]; $cart->getBillingAddress()->addData($orderData['shipping_address']); $cart->getShippingAddress()->addData($orderData['shipping_address']); $shippingRate->setCode('flatrate_flatrate')->getPrice(1); $cart->getShippingAddress()->addShippingRate($shippingRate); $cart->setPaymentMethod('cashondelivery'); $cart->setInventoryProcessed(false); $cart->getPayment()->importData(['method' => 'cashondelivery']); $cart->collectTotals(); $cart->save(); $cart = $cartRepositoryInterface->get($cart->getId()); $order_id = $cartManagementInterface->placeOrder($cart->getId()); return $order_id; } } </code>

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...