How to Get New Arrival Product REST API in Magento 2

In this article, we will learn how to filter the products of a Magento 2 store using the REST API and we will also know how to get new arrival products REST API.

By the way, Magento 2 Provides a facility for the REST API that is well known as Swagger Module which contains all list of REST APIs resources:

Using this model, you can get the product by visualizing and testing it through REST API.

When you hit the URL of your store by typing swagger you will get the list details of all the APIs.

Like I have taken an example below, according to this example you enter your URL and hit it, then you will get the API.

Endpoint:

http://www.wishusucess.com/swagger

Here we are filtering the product on the basis of attribute and the name of that attribute is a new product.

So while filtering the product through Rest API, we will get the newly added product by filtering

 

 

Get New Arrival Products REST API

 

To filter a new product, what should be its search criteria and which method will be used, what access token will be used, the details of all these are given below.

Endpoint

https://www.wishusucess.com/rest/V1/products?searchCriteria[sortOrders][0][field]=created_at&searchCriteria[pageSize]=10

Method: GET

Header: 

  • Authorization: Bearer <admin token>
  • Content Type: application/json

Body: none

New Arrival Products REST API

Search Parameter for New Arrivals in REST API

 

Created At New Arrivals

Response:

{
"items": [
{
"id": 2007,
"sku": "WSH08-31-Purple",
"name": "Sybil Running Short-31-Purple",
"attribute_set_id": 10,
"price": 44,
"status": 1,
"visibility": 1,
"type_id": "simple",
"created_at": "2021-12-23 09:40:40",
"updated_at": "2021-12-23 09:40:40",
"weight": 1,
"extension_attributes": {
"website_ids": [
1
],
"category_links": [
{
"position": 0,
"category_id": "28"
},
{
"position": 0,
"category_id": "35"
},
{
"position": 0,
"category_id": "2"
}
]
},
"product_links": [],
"options": [],
"media_gallery_entries": [
{
"id": 3353,
"media_type": "image",
"label": "",
"position": 1,
"disabled": false,
"types": [
"image",
"small_image",
"thumbnail"
],
"file": "/w/s/wsh08-purple_main_1.jpg"
},
{
"id": 3354,
"media_type": "image",
"label": "",
"position": 2,
"disabled": false,
"types": [],
"file": "/w/s/wsh08-purple_back_1.jpg"
}
],
"tier_prices": [],
"custom_attributes": [
{
"attribute_code": "image",
"value": "/w/s/wsh08-purple_main_1.jpg"
},
{
"attribute_code": "small_image",
"value": "/w/s/wsh08-purple_main_1.jpg"
},
{
"attribute_code": "thumbnail",
"value": "/w/s/wsh08-purple_main_1.jpg"
},
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "msrp_display_actual_price_type",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "sybil-running-short-31-purple"
},
{
"attribute_code": "required_options",
"value": "0"
},
{
"attribute_code": "has_options",
"value": "0"
},
{
"attribute_code": "tax_class_id",
"value": "2"
},
{
"attribute_code": "category_ids",
"value": [
"28",
"35",
"2"
]
},
{
"attribute_code": "description",
"value": "<p>Fortunately, it's okay to look cute while you're working out. The Sybil Running Short combines a fun, color-blocked design with breathable mesh fabric for sporty-fun style.</p>\n<p>&bull; Blue running shorts with green waist.<br />&bull; Drawstring-adjustable waist.<br />&bull; 4\" inseam. Machine wash/line dry.</p>"
},
{
"attribute_code": "size",
"value": "174"
},
{
"attribute_code": "color",
"value": "57"
}
]
}
],
"search_criteria": {
"filter_groups": [],
"sort_orders": [
{
"field": "created_at",
"direction": null
}
],
"page_size": 1
},
"total_count": 2046
}

 

Similar Posts:

Create Account REST API : How to Create an Account of Customer, Admin

Magento 2 Login REST API: How to Login Customer, Admin

Wishusucess on GitHub

Create Account REST API : How to Create an Account of Customer, Admin

In this article, I am going to explain to you how to use create account rest api in Magento 2. In this, I will also explain to you how to create customer and admin accounts using REST API.

Whenever you order a product inside the Magento store, there are three ways to do it.

By creating a customer account, we can order the product, which we call registered users or they are also called logged-in customers.

Another way is that customers can order products without registering an account, whom we know as guest users.

The third way is that the guest customer is registered only at the time of ordering.

As a guest user who logs in or creates an account when ordering
Through this article, I am going to explain how to register a client through the REST endpoint.

 

 

Admin Create Account REST API

Now if you are looking for the REST API endpoint to create Magento 2 admin users s you can follow the below steps.

 

Endpoint:

The below details are the basic structure of REST APIs to call in Magento 2.

<HTTP verb> http://<host>/rest/<scope>/<endpoint>

HTTP headers:

Through this section, we send the required authentication details and tell the Magento store that we are the authentic user who can access the requested data.

Payload:

Through this section, we send necessary valid details along with the endpoint.

POST <host>/rest/<store_code>/V1/tfa/provider/google/authenticate
{
"username": "admin",
"password": "<admin-password>",
"otp": "<otp-value>"
}

There is no API to create a Magento admin user you can get the access token of the admin user by using the rest API.

But you can create an admin account from the Magento 2 store in the admin.

Admin Panel > System > Permissions > All User > New User.

 

Response:

When you use the Magento admin rest API to get the access token that returns the admin’s access token in the following format.

4r2jdjdr11j6gmau8990hcj6qk5unh3i

Now, whenever you need to access the backend details or any other details then you have to use this token in the header for the authorization in every call and that header token validate then allows you to access the store details.

 

 

Customer REST API to Create Account

 

To create a customer, we can send all the details in the payload, in the first step I have only added four fields to create a customer in a short way.

But when you create a customer through rest API, all the other fields are optional, that's why you don't need to add all the fields in order to create customer accounts. You can create a customer by sending only four details in the payload in the Rest API.

 

Method 1: REST API to Create Customer in Magento 2

Endpoint:

POST <host>/rest/<store_code>/V1/customers
http://www.wishusucess.com/rest/V1/customers

Method: POST

Authorization: Not required

Body: raw: JSON

Headers: Content-Type: application/json

{
"customer": {
"email": "cs.hemantsingh@gmail.com",
"firstname": "Hemant",
"lastname": "Singh"
},
"password": "aaAdm378in@#123"
}

Create Account REST API in Magento 2

 

Response:

{
"id": 4,
"group_id": 1,
"created_at": "2022-01-14 18:38:21",
"updated_at": "2022-01-14 18:38:21",
"created_in": "Default Store View",
"email": "cs.hemantsingh@gmail.com",
"firstname": "Hemant",
"lastname": "Singh",
"store_id": 1,
"website_id": 1,
"addresses": [],
"disable_auto_group_change": 0,
"extension_attributes": {
"is_subscribed": false
}
}

 

Method 2: Create Customer REST API

In this step I am adding full customer details in payload else other details will be the same as the first methiod.

create customer rest api in detail

Response:

{
"id": 5,
"group_id": 1,
"default_billing": "3",
"default_shipping": "3",
"created_at": "2022-01-14 19:02:46",
"updated_at": "2022-01-14 19:02:47",
"created_in": "Default Store View",
"email": "cs.hemants@gmail.com",
"firstname": "Hemant",
"lastname": "Singh",
"store_id": 1,
"website_id": 1,
"addresses": [
{
"id": 3,
"customer_id": 5,
"region": {
"region_code": "UP",
"region": "Uttar Pradesh",
"region_id": 566
},
"region_id": 566,
"country_id": "IN",
"street": [
"Noida"
],
"telephone": "7992293862",
"postcode": "201301",
"city": "Noida",
"firstname": "Hemant",
"lastname": "Singh",
"default_shipping": true,
"default_billing": true
}
],
"disable_auto_group_change": 0,
"extension_attributes": {
"is_subscribed": false
}
}

 

If you log in to your Magento 2 store with any of the username and password details that you have given while creating the account using REST API, then it will log in successfully.

Or if you go to All Customers in the admin of the store, then your new account that has been created will appear.

Now if you want to implement login functionality using Magento rest api then you can use login rest API.

 

Read more: Magento 2 Login REST API: How to Login Customer, Admin

 

Other Post:

PayPal Account: How to Create New PayPal Account, Transfer

Wishusucess on GitHub

Magento 2 Login REST API: How to Login Customer, Admin

I am going to explain the Magento 2 login REST API for mobile applications so by using those REST APIs you can develop the application using the Magento 2 e-commerce framework.

So these APIs are basically used for the login system for the customers and admin users. You can take help of these proper rest ways to implement the login functionality.

 

 

Magento 2 Login REST API

 

To access the data of any store of your magento, first of all, you have to define yourself that you are the genuine person accessing that data.

Authentication means you have to prove as a genuine user of customer it admin that allows Magento e-commerce store to identify the access rights. It means you have the right to access (administrator, integration, client, or guest) resources of the API call.

Now if you just want to check some things as a front-end customer then you have to log in customer and for that, you have to get a customer access token.

But if you want to access internal details of the store then for that you must have to authenticate your identity and get an access token of admin details.

 

 

Magento 2 Login Rest API Customer

 

Step 1: You must have a customer account in order to get access tokens of customers. If you don't have a user account then you can create a customer account first.

Step 2: Now you have to send the customer user details like username and password in the payload with the POST method.

Step 3: Get customer access token in response.

 

API URL: {baseurl}/rest/V1/integration/customer/token

Endpoint:

https://wishusucess.com/rest/V1/integration/customer/token

Method: POST

Authorization: Not required

Body:

{
   "username":"cs.hemantsingh@gmail.com",
   "password":"Admin@#44123"
}

Magento 2 Login REST API

Response:

l2l6ccj0hwvm6pvj7uy7oflr7k7uvabv

 

 

Admin Login REST API in Magento 2

 

If any mobile application is developed using Magento eCommerce then at that time we need to login to Magento admin through rest API.

Let us know what is the complete step of admin login via REST API, by following which we can get this access token.

Step 1: You need a Magento store admin account in order to get access tokens of your stores via rest API.

Step 2: Now by hitting the below details you can get the admin access token. Along with the rest API URL you have to send the admin username and password in the payload with the POST method.

Step 3: Get admin access token in response.

 

API URL: {baseurl}/rest/V1/integration/admin/token

Endpoint: 

https://wishusucess.com/rest/V1/integration/admin/token

Method: POST

Header: Not required

Body:

{
    "username":"admin32",
    "password":"Admin555@#123"
}

Magento 2 Login REST API

Response:

9nnv93lsivrfvzyzt1cgdw8f3xnij05v

 

Read more: Magento 2.4 Installation Guide: How to Install Magento 2.4.2

 

Similar Post:

How to Make Payment Using PayPal REST API in Magento 2

Configure PayPal in Magento 2 : How to Integrate PayPal

How to Get Catalog Product Images URL Using REST API

When we create a mobile application using Magento 2 eCommerce then we use rest API to get the catalog product image URL.

This post will give you an idea about how you can get the product image and product URL from the REST API in Magento 2.

As we know without images we can give a greater user experience to our customers on any e-commerce website. Images give clarity about the product so customers get engaged with stores and sales increase.

 

Get Catalog Product Image REST API

This is a step-by-step code to get the product image URLs in Magento 2 eCommerce store.

This is useful in all kinds of situations like if you are developing a mobile application for your Magento 2 store then you need the product images so in order to show the product image you need to retrieve the image URL.

 

Step 1: Registration of ProductImageApi

first, we have to register our first API by rergistration.php file so we have to create the file in the below location.

Wishusucess/ProductImageApi/registration.php
<?php
/**
* Category: Wishusucess_ProductImageApi
* Developer: Hemant Singh Magento 2x Developer
* Website: http://wwww.wishusucess.com
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Wishusucess_ProductImageApi',
__DIR__
);

 

Step 2: Create a Module XML file

Wishusucess/ProductImageApi/etc/module.xml
<?xml version="1.0"?>
<!--
/**
* Category: Wishusucess_ProductImageApi
* Developer: Hemant Singh Magento 2x Developer
* Website: http://wwww.wishusucess.com
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Wishusucess_ProductImageApi" setup_version="1.0.2" />
</config>

 

Step 3: Declare Dependency Injection

Wishusucess/ProductImageApi/etc/di.xml
<?xml version="1.0"?>
<!--
/**
* Category: Wishusucess_ProductImageApi
* Developer: Hemant Singh Magento 2x Developer
* Website: http://wwww.wishusucess.com
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Wishusucess\ProductImageApi\Api\GetProductImage" type="Wishusucess\ProductImageApi\Model\GetProductImageUrl" />
</config>

 

Step 4: Create Web API Route Path

Wishusucess/ProductImageApi/etc/webapi.xml
<?xml version="1.0"?>
<!--
/**
* Category: Wishusucess_ProductImageApi
* Developer: Hemant Singh Magento 2x Developer
* Website: http://wwww.wishusucess.com
*/
-->
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd">
<route url="/V1/getproductimage/:sku" method="GET">
<service class="Wishusucess\ProductImageApi\Api\GetProductImage" method="getProductImageUrl"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
</routes>

 

Step 5: Get Catalog Product Image API Model Class

Wishusucess/ProductImageApi/Model/GetProductImageUrl.php

This model class has the actual login, so we have to write the following code in order to get the catalog product image URL.

<?php
/**
* Category: Wishusucess_ProductImageApi
* Developer: Hemant Singh Magento 2x Developer
* Website: http://wwww.wishusucess.com
*/
namespace Wishusucess\ProductImageApi\Model;

use Wishusucess\ProductImageApi\Api\GetProductImage;

class GetProductImageUrl implements GetProductImage {
/**
* @var \Magento\Store\Model\App\Emulation
*/
protected $appEmulation;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $storeManager;
/**
* @var \Magento\Catalog\Api\ProductRepositoryInterface
*/
protected $productRepository;
/**
* @var \Magento\Catalog\Helper\Image
*/
protected $imageHelper;
/**
* @param \Magento\Store\Model\App\Emulation $appEmulation
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
* @param \Magento\Catalog\Helper\Image $imageHelper
*/
public function __construct(
\Magento\Store\Model\App\Emulation $appEmulation,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
\Magento\Catalog\Helper\Image $imageHelper
) {
$this->appEmulation = $appEmulation;
$this->storeManager = $storeManager;
$this->productRepository = $productRepository;
$this->imageHelper = $imageHelper;
}
public function getProductImageUrl($sku) {
$storeId = $this->storeManager->getStore()->getId();
$product = $this->productRepository->get($sku);
$this->appEmulation->startEnvironmentEmulation($storeId, \Magento\Framework\App\Area::AREA_FRONTEND, true);
if (!$product) {
$response = [
[
"code" => '301',
"message" => "SKU " . $productSku . " Not Found On Magento",
],
];
return $response;
} else {
$image_url = $this->imageHelper->init($product, 'product_base_image')->getUrl();
$response = [
[
"product_image_url" => $image_url,
],
];
return $response;
}
$this->appEmulation->stopEnvironmentEmulation();
}
}

 

Step 6: Images URL API Class

Wishusucess/ProductImageApi/Api/GetProductPage.php
<?php
/**
* Category: Wishusucess_ProductImageApi
* Developer: Hemant Singh Magento 2x Developer
* Website: http://wwww.wishusucess.com
*/
namespace Wishusucess\ProductImageApi\Api;
interface GetProductImage {
/**
* @api
* @param string $sku
* @return array
*/
public function getProductImageUrl($sku);
}

 

That's it.

Now, we execute the following command.

php bin/magento s:up
php bin/magento s:s:d -f
php bin/magento c:c

Now you can test your product images rest API on the postman by hitting the web route URL.

Get Catalog Product Images URL

 

Now you can see the above images, here

The method is POST and the route URL path for the rest of API is your store URL address and the method and the product that you want the images path details.

https://www.your_store_url.com/rest/V1/products/sku

or

https://www.your_store_url.com/rest/V1/getproductimage/sku

GitHub Wishusucess

 

Online Help & Support for Magento 2 REST API

If you need any kind of help and support in Magento 2 rest API then you can call me.

I am always available to support you while extension development REST API development or any help related to Magento 2 stores.

I am giving you the helpline details in the below images.

Magento 2 Free Help and Support

 

Similar Post:

Search REST API: How to Find Product in Magento 2 Using REST API

Payment API: How to Make Payment Through REST API in Magento 2

RMA Extension Magento 2: What is RMA and How it Works

RMA (Return Merchandise Authorization) extension in Magento 2 enables customers to manage returns and exchanges of any product easily.

This also helps Magento 2 websites owners to give the best user experience by giving them a clear, easy, satisfying process so the customer does not get involved with such an unnecessary step that consumes time for customers and stores owners as well.

Products return management in Magento 2 is little bit complex steps so the owners of the website need more time to make it smooth for their customers. The Wishusucess RMA extensions will help you in the proper management of the orders and returns of the products from both the storefront and the admin store side.

RMA Extension in Magento 2

 

RMA (Return Merchandise Authorization) Extension Magento 2

The RMA in Magento product management allows all the customers to return products without a login on their account and order the product without creating an account.

You can show this features link on the footer or header or on the homepage so any customer can see and raise requests conveniently.

 

Compatibility And Installation of RMA

The Wishusucess Magento RMA extension is compatible with the Magento 2.1X, 2.2X, 2.3X, and 2,4X versions.

  • Customers can return any number of purchased products by just submitting their order number and email details.
  • Admin can create a return number from the backend.
  • Magento 2 Store owners can communicate by using this extension.
  • Admin user has the right to change the status of the return package.

RMA Extension in Magento 2

 

RMA Customer And Admin Functionality

The Wishusucess RMA extension in Magento 2 offers similar functionality for both customers and admin that can create the return request of any purchased products.

The customer has to go inside the “My Account” section in order to create a request for the purchased product. and Admin can create a request from the admin menu list of "RMA".

Admin can also track the customer history details of any returned products in the past.

 

How is RMA Extension in Magento 2 beneficial?

Your customers trust your website, even more, when they have a good experience.

You will be able to gain the trust of your customers through our RMA extension and they will make more purchases from your e-commerce website as this extension will go a long way in improving the shopping experience for the customers.

Customers will be able to easily return the wrong product without wasting time in the return process and store owners will be able to make the option of returning the product easy for their customers.

Wishusucess RMA extension in Magento 2 helps you to manage returns and exchanges purchased products by customers on an online store that helps any brand to improve their brand loyalty, customer retention, and customer satisfaction. This extension will also help you to build long-lasting customer relationships with your brand.

Magento 2 Free Help and Support

 

 

Similar Post:

Google reCAPTCHA in Magento 2: How to Add reCaptcha

Shop By Brand: Magento 2 Shop By Brand Free Extension

 

Other Post:

PayPal Account: How to Create New PayPal Account, Transfer

Magento 2.4 Installation Guide: How to Install Magento 2.4.2

Magento 2 Get Product Total, Subtotal, Coupon, Tax Details Via REST API

Often when we create an application, we have to get all the data of the customers via cart totals API so that we can successfully make the payment to the customer by counting the total at checkout correctly.

In this post, I will tell you how to get the total of customer's cart items how you can get all data through Magento rest api.

First of all, you add the item to the cart, after that you will get the details of all the products added to that cart through the endpoint given below.

Now you will not see subtotals, coupons discounts, tax details, etc in the cart details. For this, we have to follow other Rest API.

 

Step 1: Get Cart Items Details Via Cart Totals API

Method: GET

Endpoint:

https://wishusucess.com/rest/V1/carts/mine/

Payload: Not required

customer Cart products in Magento 2 Api

Response:

{

"id": 133,

"created_at": "2021-12-06 12:37:31",

"updated_at": "2021-12-08 08:57:31",

"is_active": true,

"is_virtual": false,

"items": [

{

"item_id": 283,

"sku": "test-product-3",

"qty": 1,

"name": "test-product-3",

"price": 3,

"product_type": "simple",

"quote_id": "133",

"extension_attributes": {

"image": "/1/_/1_1_2.png"

}

},

{

"item_id": 284,

"sku": "test-product-4",

"qty": 1,

"name": "test-product-4",

"price": 5,

"product_type": "simple",

"quote_id": "133",

"extension_attributes": {

"image": "/1/_/1_5.jpg"

}

},

{

"item_id": 285,

"sku": "Chilli Happy 10gm",

"qty": 2,

"name": "Indus Happy Hybrid Chilli seeds 10gm + 10gm - Offer Buy 1 Get 1",

"price": 900,

"product_type": "simple",

"quote_id": "133",

"extension_attributes": {

"image": "/2/_/2_7.jpg"

}

},

{

"item_id": 290,

"sku": "Kalichakra – Metarhizium anisopliae",

"qty": 3,

"name": "Kalichakra – Metarhizium anisopliae (Wettable Powder) BioInsecticide (IPL)",

"price": 200,

"product_type": "simple",

"quote_id": "133",

"extension_attributes": {

"image": "/k/a/kalichakra_ipl_455x455.jpg"

}

}

],

"items_count": 4,

"items_qty": 7,

"customer": {

"id": 58,

"group_id": 1,

"default_billing": "35",

"default_shipping": "35",

"created_at": "2021-11-29 06:44:25",

"updated_at": "2021-12-06 11:36:53",

"created_in": "Default Store View",

"email": "test@test.test",

"firstname": "Test 11",

"lastname": "Test",

"store_id": 1,

"website_id": 1,

"addresses": [

{

"id": 35,

"customer_id": 58,

"region": {

"region_code": "UP",

"region": "Uttar Pradesh",

"region_id": 566

},

"region_id": 566,

"country_id": "IN",

"street": [

"H-21",

"First Floor",

"Sector 63"

],

"company": "Wishusucess.com ",

"telephone": "+91987654321",

"postcode": "201301",

"city": "Noida",

"firstname": "Test 11",

"lastname": "Test",

"default_shipping": true,

"default_billing": true

}

],

"disable_auto_group_change": 0,

"extension_attributes": {

"is_subscribed": false

},

"custom_attributes": [

{

"attribute_code": "device_token",

"value": "caXHLarRSmqWWq8pXPRJfR:APA91bFYIxmFVF-ouwEKvmIMVV04dXki2o2LOh5ysG9Hk7BA05VqSV491i83LafAFSmCOhVAC8ZRcJVXSH_NNNdOGunSQHIHRSl0rbIbWDypCvLvxLCZZnu74s3dHwaABiIqtXGE9wB2"

},

{

"attribute_code": "is_approved",

"value": "approved"

}

]

},

"billing_address": {

"id": 495,

"region": "Uttar Pradesh",

"region_id": 566,

"region_code": "UP",

"country_id": "IN",

"street": [

"H-21",

"null - First Floor"

],

"telephone": "+9187787888",

"postcode": "201301",

"city": "Noida",

"firstname": "Test 11",

"lastname": "Test",

"customer_id": 58,

"email": "test@test.test",

"same_as_billing": 1,

"save_in_address_book": 0

},

"orig_order_id": 0,

"currency": {

"global_currency_code": "USD",

"base_currency_code": "USD",

"store_currency_code": "USD",

"quote_currency_code": "USD",

"store_to_base_rate": 0,

"store_to_quote_rate": 0,

"base_to_global_rate": 1,

"base_to_quote_rate": 1

},

"customer_is_guest": false,

"customer_note_notify": true,

"customer_tax_class_id": 3,

"store_id": 1,

"extension_attributes": {

"shipping_assignments": [

{

"shipping": {

"address": {

"id": 496,

"region": "Uttar Pradesh",

"region_id": 566,

"region_code": "UP",

"country_id": "IN",

"street": [

"H-21",

"null - First Floor"

],

"telephone": "+9198878898",

"postcode": "201301",

"city": "Noida",

"firstname": "Test 11",

"lastname": "Test",

"customer_id": 58,

"email": "test@test.test",

"same_as_billing": 1,

"save_in_address_book": 0

},

"method": "freeshipping_freeshipping"

},

"items": [

{

"item_id": 283,

"sku": "test-product-3",

"qty": 1,

"name": "test-product-3",

"price": 3,

"product_type": "simple",

"quote_id": "133",

"extension_attributes": {

"image": "/1/_/1_1_2.png"

}

},

{

"item_id": 284,

"sku": "test-product-4",

"qty": 1,

"name": "test-product-4",

"price": 5,

"product_type": "simple",

"quote_id": "133",

"extension_attributes": {

"image": "/1/_/1_5.jpg"

}

},

{

"item_id": 285,

"sku": "Chilli Happy 10gm",

"qty": 2,

"name": "Indus Happy Hybrid Chilli seeds 10gm + 10gm - Offer Buy 1 Get 1",

"price": 900,

"product_type": "simple",

"quote_id": "133",

"extension_attributes": {

"image": "/2/_/2_7.jpg"

}

},

{

"item_id": 290,

"sku": "Kalichakra – Metarhizium anisopliae",

"qty": 3,

"name": "Kalichakra – Metarhizium anisopliae (Wettable Powder) BioInsecticide (IPL)",

"price": 200,

"product_type": "simple",

"quote_id": "133",

"extension_attributes": {

"image": "/k/a/kalichakra_ipl_455x455.jpg"

}

}

]

}

]

}

}

 

Read more: How to Get Image URL in Customer Cart Using RESTb API

Step 2: Magento 2 Cart Totals API

Now, here you have to hit the following endpoint in order to get the total, subtotals, grand totals, discount amount, shipping details, tax detail, etc. via rest API.

Method: GET

Endpoint:

https://wishusucess.com/rest/V1/carts/mine/totals

Payload: Not required

Get Cart Totals APIResponse:

{

"grand_total": 2408,

"base_grand_total": 2408,

"subtotal": 2408,

"base_subtotal": 2408,

"discount_amount": 0,

"base_discount_amount": 0,

"subtotal_with_discount": 2408,

"base_subtotal_with_discount": 2408,

"shipping_amount": 0,

"base_shipping_amount": 0,

"shipping_discount_amount": 0,

"base_shipping_discount_amount": 0,

"tax_amount": 0,

"base_tax_amount": 0,

"weee_tax_applied_amount": null,

"shipping_tax_amount": 0,

"base_shipping_tax_amount": 0,

"subtotal_incl_tax": 2408,

"shipping_incl_tax": 0,

"base_shipping_incl_tax": 0,

"base_currency_code": "USD",

"quote_currency_code": "USD",

"items_qty": 7,

"items": [

{

"item_id": 283,

"price": 3,

"base_price": 3,

"qty": 1,

"row_total": 3,

"base_row_total": 3,

"row_total_with_discount": 0,

"tax_amount": 0,

"base_tax_amount": 0,

"tax_percent": 0,

"discount_amount": 0,

"base_discount_amount": 0,

"discount_percent": 0,

"price_incl_tax": 3,

"base_price_incl_tax": 3,

"row_total_incl_tax": 3,

"base_row_total_incl_tax": 3,

"options": "[]",

"weee_tax_applied_amount": null,

"weee_tax_applied": null,

"name": "test-product-3"

},

{

"item_id": 284,

"price": 5,

"base_price": 5,

"qty": 1,

"row_total": 5,

"base_row_total": 5,

"row_total_with_discount": 0,

"tax_amount": 0,

"base_tax_amount": 0,

"tax_percent": 0,

"discount_amount": 0,

"base_discount_amount": 0,

"discount_percent": 0,

"price_incl_tax": 5,

"base_price_incl_tax": 5,

"row_total_incl_tax": 5,

"base_row_total_incl_tax": 5,

"options": "[]",

"weee_tax_applied_amount": null,

"weee_tax_applied": null,

"name": "test-product-4"

},

{

"item_id": 285,

"price": 900,

"base_price": 900,

"qty": 2,

"row_total": 1800,

"base_row_total": 1800,

"row_total_with_discount": 0,

"tax_amount": 0,

"base_tax_amount": 0,

"tax_percent": 0,

"discount_amount": 0,

"base_discount_amount": 0,

"discount_percent": 0,

"price_incl_tax": 900,

"base_price_incl_tax": 900,

"row_total_incl_tax": 1800,

"base_row_total_incl_tax": 1800,

"options": "[]",

"weee_tax_applied_amount": null,

"weee_tax_applied": null,

"name": "Indus Happy Hybrid Chilli seeds 10gm + 10gm - Offer Buy 1 Get 1"

},

{

"item_id": 290,

"price": 200,

"base_price": 200,

"qty": 3,

"row_total": 600,

"base_row_total": 600,

"row_total_with_discount": 0,

"tax_amount": 0,

"base_tax_amount": 0,

"tax_percent": 0,

"discount_amount": 0,

"base_discount_amount": 0,

"discount_percent": 0,

"price_incl_tax": 200,

"base_price_incl_tax": 200,

"row_total_incl_tax": 600,

"base_row_total_incl_tax": 600,

"options": "[]",

"weee_tax_applied_amount": null,

"weee_tax_applied": null,

"name": "Kalichakra – Metarhizium anisopliae (Wettable Powder) BioInsecticide (IPL)"

}

],

"total_segments": [

{

"code": "subtotal",

"title": "Subtotal",

"value": 2408

},

{

"code": "shipping",

"title": "Shipping & Handling (Free Shipping - Free)",

"value": 0

},

{

"code": "tax",

"title": "Tax",

"value": 0,

"extension_attributes": {

"tax_grandtotal_details": []

}

},

{

"code": "grand_total",

"title": "Grand Total",

"value": 2408,

"area": "footer"

}

]

}
Similar Posts:

 

As a Magento 2 developer, while creating your store, you have to get much information through APIs such as shopping cart item, subtotal, grand total, billing and shipping address, etc., and all we can be get through the above endpoints.

 

Conclusion of Cart Totals API

By following the above steps you can get detailed data on the cart items of a customer such as subtotal, grand total, and billing & shipping address. Here are four approaches:

  • Get items information of your carts.
  • Get items quantity in the cart and the total products in the cart.
  • Get items total price and grand total price in customer cart.
  • Get the billing and shipping addresses of the customer.

Wishusucess GitHub

Search REST API: How to Find Product in Magento 2 Using REST API

If you also want to provide a product search facility to your customer for your mobile application, then for this the Magento Rest API is being explained in detail below.

I hope this post will be helpful in making the search facility better and more relevant while connecting your Magento store to the mobile application.

How to search products details and their other information with image details are given with the search endpoint.

There is two default endpoint for searching products in Magento 2 store:

  • GET V1/search
  • GET V1/products

Through GET V1/search endpoint, both the registered customers and guest customers can search the product on Magento's store, for that they do not need any admin authentication.

Through the GET V1/products endpoint, we can search the whole store but we need an authentication token to verify the request.

This endpoint has direct access to product data.

 

Read more: List of all Search REST API

 

Search By Name From a Category Magento 2 REST API

As you can see in the below image below that we have searched the product from one category on the basis of name and the detail found is only data from one category.

Method: GET

Endpoint: 

http://wishusucess.com/rest/all/V1/products?searchCriteria[filter_groups][0][filters][0][field]=name&searchCriteria[filter_groups][0][filters][0][value]=%NEMATOFREE%25&searchCriteria[filter_groups][0][filters][0][condition_type]=like&searchCriteria[filter_groups][0][filters][1][field]=name&searchCriteria[filter_groups][0][filters][1][value]=%25Parachute%25&searchCriteria[filter_groups][0][filters][1][condition_type]=like

Payload: Not required

Search REST API Magento 2

 

Search Product By SKU Using REST API

We can also search the store's data on the basis of SKU, for that you can use the below-given method along with payload and endpoint, you will get the product on the basis of SKU search.

Method: GET

Endpoint:

https://wishusucess.com/rest/all/V1/products?searchCriteria[filter_groups][0][filters][0][field]=sku&searchCriteria[filter_groups][0][filters][0][value]=test-product-4&searchCriteria[filter_groups][0][filters][1][field]=sku&searchCriteria[filter_groups][0][filters][1][value]=test-product-3&searchCriteria[filter_groups][0][filters][2][field]=sku&searchCriteria[filter_groups][0][filters][2][value]=test-product-1

Payload: Not required

search product by sku REST API

 

In the above image, you can see the params details, I have given the sku "test-product-1" and we have received all data that belong to the similar sku.

 

Read more:

Payment Method: How to Configure Payment Methods in Magento 2

 

Get Product By Price API Endpoint

Method: GET

Endpoint:

https://wishusucess.com/rest/all/V1/products?searchCriteria[filter_groups][1][filters][0][field]=price&searchCriteria[filter_groups][1][filters][0][value]=10&searchCriteria[filter_groups][1][filters][0][condition_type]=from&searchCriteria[filter_groups][2][filters][0][field]=price&searchCriteria[filter_groups][2][filters][0][value]=100&searchCriteria[filter_groups][2][filters][0][condition_type]=to

Payload: Not required

search by price rest api Magento 2

Here, If you want to search products on the basis of price, then we have to give the price range, the range we can decide from x to y.

 

Similar Post:

Payment Gateways: List of Best Online Payment Method Option in 2022

Payment API: How to Make Payment Through REST API in Magento 2

Payment API: How to Make Payment Through REST API in Magento 2

Nowadays, the mobile application has huge demand so providing the payment option by using mobile needs API to get the details and make payment done.

In this method, you can use the payments Magento 2 REST API to get the details and securely accept mobile payments through the mobile.

Magento 2 has many default payment methods so it depends on the customer-owner how they are going to give the customer experience. You can choose to make enable or disable that payment method.

The use of the PayPal payment method using REST API in Magento 2 can accept credit cards, debit cards to make payments done.

Magento Payment API

Cash On Delivery Payment API Configuration

If you are looking for the cash on delivery method option in Magento 2 then you can enable this payment method from

Admin > Stores > Configuration > Sales > Payment Method

You will see the COD option to enable and disable under other payment methods and set Enabled to Yes.

You can also set payment applicability countries.

 

Read more: How to Add Product in Cart Using REST API in Magento 2

Magento 2 Cash on Delivery REST API

This method allows the business owner to accept payment through the cash on delivery (COD) method from specific countries. Here you can also configure with minimum and maximum order total limits using COD REST API.

Method: GET

Endpoint:

https://wishusucess.com/rest/V1/carts/mine/payment-information

Payload: Not RequiredPayment Method Options in Magento 2Response:

{

"payment_methods": [

{

"code": "checkmo",

"title": "Check / Money order"

},

{

"code": "cashondelivery",

"title": "Cash On Delivery"

},

{

"code": "purchaseorder",

"title": "Purchase Order"

},

{

"code": "razorpay",

"title": "Razorpay"

}

],

"totals": {

"grand_total": 125,

"base_grand_total": 125,

"subtotal": 120,

"base_subtotal": 120,

"discount_amount": 0,

"base_discount_amount": 0,

"subtotal_with_discount": 120,

"base_subtotal_with_discount": 120,

"shipping_amount": 5,

"base_shipping_amount": 5,

"shipping_discount_amount": 0,

"base_shipping_discount_amount": 0,

"tax_amount": 0,

"base_tax_amount": 0,

"weee_tax_applied_amount": null,

"shipping_tax_amount": 0,

"base_shipping_tax_amount": 0,

"subtotal_incl_tax": 120,

"shipping_incl_tax": 5,

"base_shipping_incl_tax": 5,

"base_currency_code": "USD",

"quote_currency_code": "USD",

"items_qty": 1,

"items": [

{

"item_id": 289,

"price": 120,

"base_price": 120,

"qty": 1,

"row_total": 120,

"base_row_total": 120,

"row_total_with_discount": 0,

"tax_amount": 0,

"base_tax_amount": 0,

"tax_percent": 0,

"discount_amount": 0,

"base_discount_amount": 0,

"discount_percent": 0,

"price_incl_tax": 120,

"base_price_incl_tax": 120,

"row_total_incl_tax": 120,

"base_row_total_incl_tax": 120,

"options": "[]",

"weee_tax_applied_amount": null,

"weee_tax_applied": null,

"name": "SANJEEVNI®/SANJEEVNI+ Trichoderma wrap Biofungicide (IPL)"

}

],

"total_segments": [

{

"code": "subtotal",

"title": "Subtotal",

"value": 120

},

{

"code": "shipping",

"title": "Shipping & Handling (Flat Rate - Fixed)",

"value": 5

},

{

"code": "tax",

"title": "Tax",

"value": 0,

"extension_attributes": {

"tax_grandtotal_details": []

}

},

{

"code": "grand_total",

"title": "Grand Total",

"value": 125,

"area": "footer"

}

]

}

}

 

Step 2: Make Payment With COD REST API

Now, we got all the available payment methods in Magento 2 websites through the REST API so, In order to complete this payment, we have to send the payment method and the billing address along with it.

Method: POST

Endpoint:

https://wishusucess.com/rest/V1/carts/mine/payment-information

Payload:

{

"paymentMethod": {

"method": "cashondelivery"

},

"billing_address": {

"email": "cs.hemantsinghsparx@gmail.com",

"region": "Uttar Pradesh",

"region_id": 566,

"region_code": "UP",

"country_id": "IN",

"street": ["Noida, Noida"],

"postcode": "201301",

"city": "Noida",

"telephone": "7992293862",

"firstname": "Hemant",

"lastname": "Singh"

}

}

Payment Cash on Delivery

Response: 79

Now we will get the order confirmation response.

 

Other Posts:

Razorpay Payment: Step By Step Guide to Integrate Payment Method

Product Order Payload: How To Order Product Using Magento 2 REST API

Product Order Payload: How To Order Product Using Magento 2 REST API

In this Magento2 article, I am going to explain order flow using Rest API. Here, I am going to show you each step of the Magento 2 product order payload and their endpoint in detail.

It is mostly used for making mobile applications.

When we create a generic android mobile app time it is used to access and communicate data from the Magento 2 website and also used to implement basic features for any kind of mobile application using the Magento shopping framework.

Today there are so many options available to make payment in Magento, whether it is PayPal or Razorpay, or any other payment method when we want to pay it through rest API in the mobile application then usually we face the problem of transaction id or payment id. So this article will help you while Magento 2 payment gateway interaction in a Mobile application using REST API.

 

Step 1: Generate Customer Access Token

In the first step we need to generate the customer access token then only we can move to the next step to add a cart to a customer account.

In the POST request enter your store URL along with this endpoint.

Method: POST

Endpoint: www.wishusucess.com/rest/V1/integration/customer/token

Payload:

{  
"username": "cs.hemantsingh@gmail.com", 
"password": "Addddmin@#123" 
}

customer token creation api

Step 2: Create a Cart - Product Order Payload

Now, in the second step we will create a cart by using Magento 2 REST API, So in order to add items in the cart using rest API will contain the customer’s authorization token in the authorization header.

Method: POST

Endpoint:

https://wishusucess.com/rest/default/V1/carts/mine

Scope: default store view

Headers:

  • Content-Type: application/json
  • Authorization: Bearer n785dukrtbh4dhhuqfvc4aaito60ju1f

add to cart api

 


How to Get Quote ID in Magento 2 REST API

We can get the Quote ID by using rest/default/V1/carts/mine endpoint with the POST method.

Note: Now we have the response and the response quoteId is 119.

How to Check Product Availability?

We can check product availability by using the following rest API in Magento 2.

https://wishusucess.com/rest/default/V1/inventory/get-product-salable-quantity/SKU/2

Now we have ensured by checking the salable quantity that we have enough quantity of products in stock so we can order the potential order.


 

Step 3: Add Products to Cart Using REST API

So, in the third step, we can add products to the cart by using the following details.

Method: POST

Endpoint: 

https://www.wishusucess.com/rest/default/V1/carts/mine/items

Headers:

  • Content-Type: application/json
  • Authorization: Bearer <customer_token>

Payload:

{
"cartItem": {
"sku": "test-product-2",
"qty": 2,
"quote_id": "3"
}
}

rest api for add to cart using quote id

Read More: Add To Cart REST API for All Type of Products

 

Step 4: Get All Payment Information Using API

So, in the fourth step, we can check the list of available payment information to make payment done using API.

Method: GET

Endpoint: 

https://wishusucess.com/rest/V1/carts/mine/payment-information

Headers:

  • Content-Type: application/json
  • Authorization: Bearer <customer_token>

Payload:

  • Not Required

Product Order Payload

So now using the above Magento 2 REST API we can get all available payment methods in Magento 2.

 

Step 5: Save Payment Information and Order

In this step, we will use the post method to save the information and send the payment method type to complete the payment. Then only orders will be created by Magento 2 REST API. After successful order creation customer will receive the response of order confirmation.

Endpoint:

https://wishusucess.com/rest/V1/carts/mine/payment-information

Headers:

  • Content-Type application/json
  • Authorization Bearer ikdvclhbdr8a13473hyf3vdxq9m7ouh2

Payload:

{
"paymentMethod": {
"method": "cashondelivery"
},
"billing_address": {
"email": "cs.hemantsingh@gmail.com",
"region": "Uttar Pradesh",
"region_id": 566,
"region_code": "UP",
"country_id": "IN",
"street": [
"PMO Appartment"
],
"postcode": "201301",
"city": "Noida",
"telephone": "7992293862",
"firstname": "Hemant",
"lastname": "Singh"
}
}

Product Order PayloadResponse: 74


 

Related Article:

Cart Images: Get Product Image in Customer Cart Magento 2 REST API

How to Send Push Notifications on Android Application

Product Alert API: Get Magento 2 Product Alert Using API

Login With Number: Magento 2 Customer Login With Mobile Number

In this article, I am going to explain how to implement Magento 2 login customer via phone number functionality in Magento 2 and onwards version.

As we want to add the customer log-in functionality for the customer login with numbers like phone numbers or mobile numbers with the same fields.

So, in order to achieve this functionality, we have to implement the module.

Customer Login With Number in Magento 2

 

Why Customer Login With Phone Number?

When a customer wants to log in with the email then the customer will be able to log in or if the customer wants to login via their phone number then also that can be login.

Today everyone has a lack of time in this digital era, in such a situation, if we do not provide various facilities to our customers, then our customers will leave us.

That's why keeping in mind our customers, we cannot harass them by filling the registration form again and again.

They should have so much facility that they can log in as they want.

The Magento development company named Wishusucess.com has developed a module that can help your customer to log in via their mobile number or phone number or email id and password.

This module has important features that include Magento store customers can save their number while registration of their account, and they will also have the facilities to log in to their account and update their mobile number or phone number from their My Account section.

 

Features of Customer Log Via Number:

Customers can log in via their email or phone number or mobile number or both.

This customer login via the Mobile number module can be enabled or disabled from the admin panel.

Customers also can save their number while registering or after the registration from the My Account sections dashboard.

Allows customers to change their registered mobile number from their "My Account" section

Admin will have the option in the backend to view and update any customer number or phone number.

While checkout the product order customer also can log in via their mobile number or phone number.

Customer Login Via Mobile Number

Download the Module  From GitHub

Current Product Version - 2.4.x

Supported Framework Version - Magento 2.0.x, 2.1.x, 2.2.x,2.3.x, 2.4.x

Admin > Customers > All Customer > Account Information Magento 2 Customer Login With Number

 

Sorting Products: Magento 2 REST API For Sort By Product on List Page

 

Customer Account Information

However, Navigating into the admin panel

Customers > All Customers and view the list of customers.

You can also directly edit the customer numbers from this dashboard section.Customer Login With Number

Customer Image: Upload Customer Profile Pic Image Module in Magento 2

Customer Attribute: How to Add Custom Customer Attribute in Magento 2