I was experimenting on Shopify
since I started learning Shopify
recently. I' a MEAN stack
developer. One thinking came to my mind that how do we update the shipping charges dynamically?
Here is my plan,
There will be a Google Maps
and the usine will pick the location. I've added few fields to the cart.liquid
by reffering to THIS page.
I've created a small Embedded App
to initiate the maps. The app uses NodeJS
, Koa
, NextJS
, and React
and I'm planning to create an Endpoint
with Koa
where I can calculate the shipping charges based on the Geometric distance from User location to Store location.
The calculation will be something like below.
let latA = /* Store Lat */
let lngA = /* Store Lng */
let latB = /* User Lat */
let lngB = /* User Lng */
/* I'll caculate the distance using Google maps API. Lets say, distance is 10KM */
let shippingCharge = 10 * 50;
I can get this value and set it as Cart Attribute
. But I want to collect the amount from the user, so, Is there any way to send this to checkout page as shipping charge?
I can't use Shopify
shipping methods since my shipping charge will be created dynamically.