Magento 2 API: Add Products to Cart & Checkout Place Order

In this article, we will look into how we can add products to the cart and complete the checkout process by placing an order using Magento API. The APIs used to create a cart, add products to the cart, place an order, etc. require customer token authentication. Create Shopping Cart We create an empty cart … Read more

Magento: Create Order Programmatically

This article show how you can create sales order programmatically through code in Magento 1.x. This code example also includes creating new customer if the customer email is not already registered. It also shows how you can save customer address to the newly created customer. This code has been tested for simple products. Here are … Read more

Magento 2: Get Product’s Custom Option Value from Cart & Order

This article shows how to get custom option values of products/items added to cart or products of any order in Magento 2. I will simply be using ObjectManager for this example. Get custom options of products present in shopping cart $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $cart = $objectManager->get('\Magento\Checkout\Model\Cart'); // get cart items $items = $cart->getItems(); // get … Read more

Magento 2: Get all shopping cart items, subtotal, grand total, billing & shipping address

This article shows how to get shopping cart items/products, subtotal and grand total of cart, and shipping and billing address entered while doing checkout in Magento 2. I will be using both Dependency Injection (DI) and Object Manager in the below example code. Using Object Manager – Get products id, name, price, quantity, etc. present … Read more

Magento 2: Set Unset Get Session

This article shows how to create and destroy different types (Checkout, Customer, Catalog) of sessions in Magento 2. As you can see below, there are different types of session classes present in Magento 2. vendor/magento/module-catalog/Model/Session.php vendor/magento/module-newsletter/Model/Session.php vendor/magento/module-persistent/Model/Session.php vendor/magento/framework/Message/Session.php vendor/magento/module-customer/Model/Session.php vendor/magento/module-backend/Model/Session.php vendor/magento/module-checkout/Model/Session.php In below example code, I will be dealing with Catalog, Customer, and Checkout sessions. … Read more

Magento: Redirecting to Cart page from Checkout page after Place Order

Scenario: I added products to cart. Then did proceed to checkout. I have tried Cash on Delivery and Check / Money Order as Payment method. Everything is fine until the order review section. And then when I click the Place Order button then it gets redirected to Cart page instead of going to Order Success … Read more

Magento: Paypal Express Checkout Showing Empty Order Data [FIXED]

I am using Magento verion 1.4.0.1 and I had this issue. I had enabled Paypal Express Checkout payment method. When I choose this method on checkout, I was redirected to Paypal website but order data was not displayed there. The main reason in my case was due to applied discount to the cart. I had … Read more

Magento: Payment method not displayed in Multiple Shipping Adresses Checkout

Problem: I have a payment method which is displayed well in general Magento checkout. But it is not displayed in Multiple Addresses Checkout. Solution: Please see the Model class of your payment module. The following variable should be set as true. /** * available for multi shipping checkouts */ protected $_canUseForMultishipping = true; Write the … Read more