- Posts: 175
- Thank you received: 0
Hikashop Shipping
hello
i've been trying to develop a shipping plugin that can handle multiple shipping price from different source
Context : these 4 shipping methods are same shipping method but with different parameters in backend/configuration file
the one with "free shipping" means it's not a available, how to disable it so when user click on it then it wont save/cannot pick the one with free shipping??
If i click any of the free shipping [shouldve been disabled] method and click on the one with price, it will show free shipping on other shipping method
If i click the one thats available , it will show the real number [after previously "free shipping"]
However when i click next after picking the shipping, it returned to free shipping [the shipping price is gone again]
my code is :
Any suggestion what should i do? Am i doing it wrong?
Thank You
Please Log in or Create an account to join the conversation.
The shipping plugins implement the trigger onShippingDisplay:
www.hikashop.com/support/documentation/6...ml#onShippingDisplay
The variable $methods contains all the shipping methods loaded from the database.
The variable $usable_methods contains all the shipping methods that will be displayed.
By default the variable $usable_methods is an empty array, and each shipping plugin modify and copy the methods from $methods to $usable_methods so that they can be displayed.
Thus it's really easy to remove the methods from the selection area when they shouldn't be available. Just don't add them in the $usable_methods array in the onShippingDisplay method of your shipping plugin.
Please Log in or Create an account to join the conversation.
Thank You, it works now
However there is a bug where if user create a new address, it kinda reset the shipping choices and set the shipping price 0
It shows that my calculation works fine here is my code
//rate = method
//usable_rates = usable_method
$rate->shipping_price = $real_cost;
$usable_rates[$rate->shipping_id]=$rate;
This bug only occured if there is only 1 option available, [if there is 2 option out of 4 available, it will choose the 1st one]
edit : looks like it still used any shipping method the user choose before creating a new address and because the new address doesnt have that option available, it shows free shipping as the result is 0 (???)
If i pick another address and pick the one i just created, it will fix and show the real shipping price
Any suggestion what should i do? Thank You
Edit 2 :
I also noticed that the shipping will reset to 0 when i click the checkout button from cart
After changing address, the shipping price will be fixed
any suggestion what should i do? Why its resetting to 0?
Thanks
edit 3 : is there is a system that somehow store shipping methods? i noticed that the selected shipping methods are saved , even when i clicked the checkout button it will keep the previous settings? is it possible to force it to refresh shipping method everytime they open checkout?
thanks
Please Log in or Create an account to join the conversation.
Hard to say anything useful.
I don't know the full code of your shipping plugin, I don't know how you configured your checkout, etc.
Could you provide the full code of the plugin, a screenshot of the settings of your shipping method and a screenshot of the settings under the "checkout" tab of the HikaShop configuration ?
Please Log in or Create an account to join the conversation.
nicolas wrote: Hi,
Hard to say anything useful.
I don't know the full code of your shipping plugin, I don't know how you configured your checkout, etc.
Could you provide the full code of the plugin, a screenshot of the settings of your shipping method and a screenshot of the settings under the "checkout" tab of the HikaShop configuration ?
Sure!
Shipping Setting :
checkout settings
EDIT :
If user change their address's city [that is the parameter that is used by my shipping script] the shipping method of first method will be turned into free shipping.I have var_dump the variable and everything is working fine just like the other 2
if i select another address and then select the one that i just created/changed, then it works normally. Any suggestion?
edit 2 :
If i select other shipping method, that method turned into free shipping ??
note : these 3 methods are the same method but with different parameters in their setting/configuration
Please Log in or Create an account to join the conversation.
The function onShippingDisplay looks correct. The onShippingSave function should not be necessary.
The shipping methods are indeed cached to avoid doing too much unecessary cURL.
I would recommend to add that attribute to your shipping plugin class:
var $use_cache = false;
That will deactivate the cache for your plugin. It will probably help when you do your tests. That's probably why you didn't see the shipping methods working properly even after fixing the onShippingDisplay function with the instructions we gave.
Please Log in or Create an account to join the conversation.