Magento
Scandiweb

Written by:Scandiweb

Follow the best! Reuters, New York Times, and JYSK now order their digital solutions in Latvia!

Friday, June 21, 2019

eSW - Magento 2 extension for creating tailored user journeys

Introduction

eShopWorld is a wonderful tool for enriching any eCommerce experience. It allows you to easily create localised shopping experience for every corner of the world. Check out this video for more information.

In this article, we go through the 3 main areas of functionality for a Magento 2 extension developed by Scandiweb that helps you make the most of eSW for your Magento 2 store. These 3 areas are price adjustment, redirection to eSW preorder/checkout, and Magento order confirmation.

1. PRICE ADJUSTMENT:

Adjusts product prices according to currency rates and custom percentage adjustments per Store View. Rates and percentages are kept in DB and synced from an external Pricing Feed. There are BE configs for what time the eSW API should be called, for how long, at what intervals, etc. There can and have been issues with price adjustments if 3rd party modules have implemented their own version of adjusting prices. It seems that price adjustment is an underdeveloped area of M2, so modules have to build their own ways of modifying prices, and not always in the Magento way.

2. REDIRECT TO PREORDER/CHECKOUT:

When products are added to the Cart, price adjustments happen with the Quote Items. The adjusted price is set as CustomPrice, taking into account the store-view-specific currency rates and percentage adjustments (math happens). When a user clicks the "Go to Checkout" button in store, a request is sent to eSW with the cart information (exact information sent can be seen in logs), they return their Checkout URL (generated based on the Brand Code (set in BE)) and the user is redirected to the eSW Checkout.

3. ORDER CONFIRMATION:

Upon finishing the eSW Checkout, the user is redirected back to Magento, where an order is made. At this point address and pricing, validation can happen if enabled in BE. If prices or addresses don't pass validation, there is an exception. Eshop is informed about the error and on their side, things are stopped too. If validation is disabled or passed, an order is made successfully.

4. FRONT-END FUNCTIONALITY:

In addition to that, the extension introduces new functionality on the store's front-end. It's as follows:

  1. Landing page functionality - modal window, shown to the customer once, allowing them to select their preferred country, language, and currency. This window is shown once per customer session.
  2. Footer bar functionality - allowing to choose same options inside page footer. These selects are always visible to the customer.
  3. Also, depending on currency chosen, the extension will update display currency for a page.
  4. The extension will provide a redirect to the respective store after translation language is changed.

Pricing

Pricing functionality is responsible for price manipulations in Magento. Pricing functionality has 2 pricing models, which are set up based on country.

CONFIGURATION

There is a separate configuration section called “Pricing” which configures which pricing model is used for which country. In order for this functionality to start working:

  1. The extension should be enabled in that particular store.
  2. Pricing feed should be enabled for that particular store.

FUNCTIONALITY FLOW

As mentioned above - there are 2 pricing models, which are described below. In order to decide which pricing model will be applied in particular, the country configuration should be done.

FX PRICING MODEL

If this pricing model is applied for the user’s selected country, then retailer adjustments should be applied to the product price after it was converted to the user’s selected currency using the Pricing feed data. Price adjustment is applied using the Magento 2 native pricing framework. But this only works in the scope of the Product model, once we start dealing with Quote item - default Quote item model had to be extended and “custom price” functions were overridden in order to provide the desired behavior.

FIXED PRICING MODEL

If this pricing model is applied for the user’s selected country, then the price for the product is specified as is (meaning without any adjustments) using product’s “Billing Price” attribute:

esw magento

With this configuration, if the user is from the UK the price of that product will be 50 GBP. If the currency is changed then the 50 GBP is converted to the selected currency. In order to provide this functionality, there is a Magento 2 interceptor that works right after the getPrice method and then using the Pricing helper returns the correct price for this product for this country.

Pricing Feed

Pricing feed functionality is responsible for delivering new data for Pricing functionality to work. Pricing feed fetches the retailer’s latest adjustments and new currency rates daily.

CONFIGURATION

This functionality requires some pre-configuration in order to start working:

  1. The extension should be enabled in that particular store.
  2. The brand code should be provided in that particular store.
  3. Subscription key should be provided in that particular store.
  4. Pricing feed functionality should be enabled in that particular store.
  5. Base API URL should be defined in that particular store.
  6. Pricing feed request path should be defined in that particular store.
  7. Pricing feed start time should be defined in that particular store.
  8. If the frequency of requests is not provided - 10 minutes will be used.

FUNCTIONALITY FLOW

Pricing feed fetches new rates daily using Cron jobs and store fetched data in the database.

Pre-order

This part of the article describes how pre-order functionality is implemented. It also describes the configuration needed for the pre-order request.

CONFIGURATION

In order for the pre-order functionality to kick in, configuration of extension should be done. Minimal required fields are described below:

  1. The extension should be enabled in that particular store.
  2. Base API URL should be defined.
  3. Pre-order request path should be defined.

FUNCTIONALITY FLOW

Functionality flow of this part of the extension can be separated into three separate stages. These are: making a decision if the customer is applicable for eSW checkout, making a request for checkout data, receiving a response and acting on it.

Order Confirmation

Description of the order confirmation mechanism below:

CONFIGURATION

There is no pre-configuration needed, for order confirmation to work. Despite that, pricing validation can be configured for order confirmation. This can be done in Magento 2 administration panel, under extension configuration. For convenience, there is store specific endpoint URL displayed in Magento 2 admin section, under extension configuration on store configuration level.

Functionality Flow

This process can be separated into several stages. These are: hitting endpoint with order confirmation data, finding customer cart, based on provided data, submitting that cart, converting it to order and sending a response back to eSW.

PREORDER REQUEST

  1. The extension is activated when a customer, after selecting a cart with products, chooses to proceed to checkout.
  2. In cases where the customer is applicable for the eSW checkout, the customer will be redirected to the eSW checkout.
  3. In cases where the extension is disabled or customer is not applicable for the eSW checkout, the customer will not be redirected to the eSW checkout but instead will be directed to domestic Magento 2 checkout.
  4. After the customer completes checkout on eSW page, they will be redirected back to the Magento 2 store. The page to which customer is redirected is configured in eSW retailer configuration page.
  5. Order is not placed in the Magento 2 store until order confirmation request is received.

ORDER CONFIRMATION REQUEST

  1. The extension provides an API endpoint for the eSW system to call for order confirmation.
  2. Endpoint is accessible by /eshopworld/order/confirm/ link on Magento 2 store installation and should be secured with HTTP AUTH. Also, this link can be confirmed by checking eSW configuration page in Magento 2 administration panel.
  3. When order confirmation request is received by this endpoint it tries to find the respective pre-order in the Magento 2 store database. Where the pre-order is found, the order is placed. In cases where preorder is not found, no action is taken.
  4. Order confirmation endpoint sends out a response to the eSW system based on eSW documentation. Response defines if order confirmation action was successful or not.

Retailers Display

This section describes front-end updates to Magento 2 provided by this extension. It can be separated into two related pieces of functionality - landing page and footer selectors.

CONFIGURATION

There is a separate configuration section, created for retailer display. This configuration controls the overall display of footer bar and landing page, also controlling display of each particular selector in each section.

LANDING PAGE

Technically, it is not a page, it is a modal window. On first customer visit, if there is no eSW landing page cookie for customer session, the landing page is shown. A landing page is a modal window, covering the whole page, where the customer can select his preferred eSW settings. After customer clicks “Continue shopping” button, selected settings are saved to the cookie and the page gets reloaded, in order to reflect selected settings. After the initial show, the landing page will never be shown to the customer in the same session.

FOOTER BLOCK

Footer block contains the same selectors, as a landing page. Footer block is shown to the customer on each page if it is enabled. After customer changes, any option in that select, page gets refreshed in order to reflect changes.

ADDITIONAL INFO

  1. Landing page and footer selectors are sharing the same data source.
  2. There is a decision-making controller, created with this extension. This controller gets called each time any setting is changed, and he decides where to redirect customer, in order to reflect his selected changes. In default, decision making happens like this: a) If the country option is changed - place cookie and refresh the page. b) If currency option is changed - place cookie, set correct currency, refresh the page. c) If language is changed - place a cookie, and redirect the customer to the store, containing this language.JS part of retailer display functionality handles only displaying of footer bar and landing page, along with managing JS events on them.


Looking to create local user checkout experiences for increased conversions? Get in touch with us at info@scandiweb.com and let's make this a reality.

loading...
Heart sign
thank you

We will contact you as soon as possible

Warning sign
something wrong

Please check fields and try again

contact us