Custom Shipping Plugin

  • Posts: 48
  • Thank you received: 0
6 years 5 months ago #281282

-- HikaShop version -- : 3.2.1
-- Joomla version -- : 3.8.1
-- PHP version -- : 5.6

Our Distributor has a webservice we are connecting to and we we are creating a custom shipping plugin. Our distributor said to display the Shipping rates useing the GetVariousFlatRates, that it will return an array of various ship methods and the cost available. My developer thinks we should use the current shipping plugins and populate the rates from there server but I am not sure that there is a function that does that. Can we display an array of shipping methods and rates brought in from our distributors WS? See link for soap call...thanks

ws.anchordistributors.com/anchorwebservi...=GetVariousFlatRates

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
6 years 5 months ago #281289

Hello,

I'm not sure to understand what "populate the rate" means.
But the idea is to having a custom shipping plugin which will store in cache the shipping rules (from the API) and use the trigger "onShippingDisplay" to push the available methods.
www.hikashop.com/support/documentation/6...tation.html#shipping
It's the same than the available shipping plugin in HikaShop (UPS, Fedex, USPS, CanadaPost, etc)

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 48
  • Thank you received: 0
6 years 5 months ago #281311

I am wanting to call the rates or display the rates from the WS @ ws.anchordistributors.com/anchorwebservi...=GetVariousFlatRates

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
6 years 5 months ago #281314

Hello,

Yes ; it does not change my previous answer : it requires custom development to create a custom plugin and the usage of the function "onShippingDisplay".

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: ChristianLocal

Please Log in or Create an account to join the conversation.

  • Posts: 48
  • Thank you received: 0
6 years 5 months ago #281343

onShippingDisplay says that "This method will be called by HikaShop when it is displaying the shipping layout of the checkout process. There, it wants to display a list of possible shipping options and asks the shipping plugins what are the possibilities for the current order information. In the $methods array, you will get all the methods found by the system which are published. You will first need to filter the $methods so that your plugin only work on your plugin method(s)" My distributor has the methods that we bring in from there server, i.e. Media mail, 2 Day Air...etc. Do we need to publish the current plugins inside of Hikashop and then populate the rates in there? or can we just display the rates from the distributors server? I hope I am explaining this correctly. thanks

Last edit: 6 years 4 months ago by ChristianLocal.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
6 years 4 months ago #281344

Hello,

We have the HikaShop partner page : www.hikashop.com/home/our-partners.html
And we also have a "commercial jobs" section in the forum : www.hikashop.com/forum/9-commercial-jobs.html

Afterwards the creation of a shipping plugin can be complicated and for what I remember regarding your request, there was some other tasks which made the final development pretty important.

Regards,

Note : Thanks to don't edit your message a long time after posted it, that mess up our work organisation, if you have to add something post a new message, thank you for your understanding.


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Last edit: 6 years 4 months ago by Philip.

Please Log in or Create an account to join the conversation.

  • Posts: 48
  • Thank you received: 0
6 years 4 months ago #283123

Problem description
Our shop delivers product to customer via our supplier.
Our supplier can deliver by different shipping company. List of shipping method and shipping companies depends on customer address and product list (total weight, item quantity, etc).

Our supplier has API (SOAP webservice). We send where and what to deliver and supplier webservice returns to us list of possible shipping methods.
There could be different shipping companies in this list. There could be the same shipping company few times but with different deliver terms (different time and cost)

Supplier’s webservice returns to us
- name and delivery time (it is single text field)
- suppliers delivery id (we should send selected shipping method back to supplier with customer’s cart)
- shipping cost

When our customer purchases out the cart, we have to show on shipping page with the list of possible shipping method. This list should contain only shipping methods that our supplier’s webservice returns for this specific customer (for this specific cart).

We could find way how we can show selected by customer shipping method without adding this selected method to Hikashop shipping methods.

Now for every purchase that our customer makes, we have to add new shipping method. Just to remind written above - we have shipping company and delivery terms inside single text field (in shipping name) and we have to send shipping id back to our supplier; so we have to store shipping name and shipping id somewhere, but show it in shipping section inside customer cart).

This solution works for us well, but we disturb that there will be 25000 new shipping method in a year (approximately we will have 25000 purchases in a year)

Questions
• Is it true solution to make new shipping method in Hikashop for every purchase?
• Is it the only solution without core modification?
• Is there a way to store shipping info somewhere in order and show this info in shipping section inside customer’s cart?



Implementation description
We created plugin inherited from hikashopShippingPlugin.
We re-declare method onShippingDisplay there.
Inside this method we request supplier’s web service.

We set $usable_rates with shipping methods we get from supplier’s web service. After this customer sees only our supplier’s shipping method.

$usable_rates = array();
foreach ($responce as $id => $data) {
$rate = clone $templateRate;
$rate->shipping_id = $id; //id from anchor
$rate->shipping_name = $data;
$rate->shipping_price = $data;
$rate->shipping_seq_id = $id; //save seq_id

$usable_rates[$id] = $rate;
}

We subscribe on event onBeforeOrderCreate.
There we load cart info first:
$cartClass = hikashop_get('class.cart'); $cart = $cartClass->loadFullCart();

Than we fetch selected shipping method and save in Hikashop shipping method.
$cart->usable_methods->shipping
$shippingClass = hikashop_get('class.shipping');
$savedId = $shippingClass->save($shipping, false);

In order set real id
$order->order_shipping_id = $savedId; //set real id form db

After this the cart (the order page shows correctly.

Last edit: 6 years 4 months ago by ChristianLocal.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
6 years 4 months ago #283128

Hello,

Generally speaking, you want to use the way that shipping plugins like UPS, USPS, Fedex, CanadaPost are working.
You got one single instance of your shipping method (one single ID) but the plugin can virtually create methods during the checkout (depending the order content).

These plugins dynamically get shipping rates (using web services) and what the customer see is the price for the products in its cart.
That shipping price (and details) are store in the order afterwards so you still have a trace of the price (and some other stuff if you need it).

So I would really recommend you to check these plugin source code in order to see how they are interacting with the web services provided by these platforms.
It would avoid you to create a lot of entries in your database ; when you just need something dynamic.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 48
  • Thank you received: 0
6 years 4 months ago #283271

we reviewed the examples in the plugins in Hikashop.

They create predefined set of shipping method
For example for FedEx they are:
FedEx Ground (USA, PUERTO RICO)
FedEx 2 Day (USA, PUERTO RICO)
FedEx Express Saver Time Pickup (USA, PUERTO RICO)
FedEx First Overnight (USA, PUERTO RICO)
FedEx Ground (Home Delivery) (USA, PUERTO RICO)
FedEx Priority Overnight (USA, PUERTO RICO)
FedEx Smart Post (USA, PUERTO RICO)
FedEx Standard Overnight (USA, PUERTO RICO)
FedEx International Ground ()
FedEx International Economy ()
FedEx International Economy Distribution ()
FedEx International First ()
FedEx International Priority ()
FedEx International Priority Distribution ()
FedEx Europe First ()
In case of Anchor WS we do not have predefined shipping methods,That is why we have to create them dynamically.

Anchor WS returns not only shipping company name by itself, but it sends in the same field shipping time.
For example, "FedEx International Ground 5-7 days" (and not just "FedEx International Ground")

The problem is about shipping method Name: the plugin can virtually create methods during the checkout it uses shipping name that are predefined. The list with fedex method (that I sent to you as example) is predefined and hardcoded in sources.

Last edit: 6 years 4 months ago by ChristianLocal.

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
6 years 4 months ago #283275

Hi,

No, these are "types of shipping", but for each type of shipping, the rates are retrieved automatically and dynamically from the shipping plateform. And that's what you want to do.
So it's really the same as these plugins, only that you have one "shipping service" instead of several.
The point of having the services as options in the shipping plugins is that it allows merchants to choose which services they want to allow or not for a shipping plateform.
So for example, if they only want to offer the standard shipping rates and not the express shipping rates of USPS, they can choose to do so, but the rates themselves will still be retrieved on the fly during the checkout.
And regarding the fact that the shipping names returned by your shipping plateform would have to be hard coded, that should not be necessary.
You can implement the shippingMethods function in your plugin to have the shipping method selected match with the shipping method instance anyway you want.
And you can add extra params to the order to store additional information about the shipping and then display it on the order if necessary.
You can see an implementation of that on that shipping plugin:
github.com/HikaShop/hikashop-envoimoinscher
For example, it has only 1 Fedex service listing in its configuration, but the envoimoinscher shipping plateform can send back several services of fedex with several prices. You can also see the extra data for pickup points added to the order in its order_shipping_params in the onBeforeOrderCreate trigger and then displayed in emails/order/etc with the onAfterOrderProductsListingDisplay trigger.

Last edit: 6 years 4 months ago by nicolas.
The following user(s) said Thank You: ChristianLocal

Please Log in or Create an account to join the conversation.

  • Posts: 48
  • Thank you received: 0
6 years 4 months ago #283342

I have relayed the info to the developers...they are in Russia so it night time now...

Please Log in or Create an account to join the conversation.

Time to create page: 0.078 seconds
Powered by Kunena Forum