[Skip to main content](#vessel-content)

#   Shipping Plugin $usable\_methods

##

- **[c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")**
- [![c0untfl0yd's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile") Topic Author
- [ Offline](/forum/user/46230-c0untfl0yd)

Less More

- Posts: 4
- Thank you received: 0
-
-

9 years 11 months ago [\#256015](#256015) by [c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")  *[Shipping Plugin $usable\_methods](/forum/28-shipping-methods/887627-shipping-plugin-usable-methods#256015 "I am developing a shipping plugin for hikashop. The plugin makes requests to an API to determine price and all other parameters.  I need to have two methods in $usable&#95;methods.  here is demo sample from my pluginName.php  after the second array&#95;push two shipping methods are displayed as expected. and also &quot;Notice: Undefined offset: 1 in C:&#92;Bitnami&#92;wampstack-5.6.27-0&#92;apache2&#92;htdocs&#92;joomla&#95;1&#92;administrator&#92;components&#92;com&#95;hikashop&#92;classes&#92;shipping.php on line 394&quot; is displayed. I need to have two methods in $usable&#95;methods and no Notice. Any help would be appreciated.  An obvious solution would be to add a new shipping method of the &quot;pluginName&quot; type from the admin panel and everything would be ok. However this doesn't work for me.")* was created by *[c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")*

I am developing a shipping plugin for hikashop. The plugin makes requests to an API to determine price and all other parameters.

I need to have two methods in $usable_methods.

here is demo sample from my pluginName.php Code:

&lt;?php defined('_JEXEC') or die('Restricted access'); require_once __DIR__.'\$_include_functions.php'; ?&gt; &lt;?php class plgHikaShopshippingpluginName extends hikashopShippingPlugin { var $multiple = true; var $name = 'pluginName'; var $doc_form = 'pluginName'; var $use_cache = true; function onShippingDisplay(&amp;$order,&amp;$methods,&amp;$usable_methods,&amp;$messages){ $pluginName_methods_object = null; foreach($methods as $key =&gt; $value){ if($methods[$key]-&gt;shipping_name === "pluginName"){ $pluginName_methods_object = $methods[$key]; } } $pluginName_methods_object-&gt;shipping_price = 14; $pluginName_methods_object-&gt;shipping_params-&gt;yadiyadiyada2_api = "yadiyadiyada2"; $pluginName_methods_object-&gt;shipping_params-&gt;yadiyadiyada3_api = "yadiyadiyada3"; array_push($usable_methods,$pluginName_methods_object); //no problems here everything is displayed fine $new_method = $pluginName_methods_object; $new_method-&gt;shipping_id = 9199; $new_method-&gt;shipping_type = 'lalalala'; $new_method-&gt;shipping_name = 'lalalala1'; array_push($usable_methods, $new_method); // problem here

after the second array_push two shipping methods are displayed as expected. and also "Notice: Undefined offset: 1 in C:\Bitnami\wampstack-5.6.27-0\apache2\htdocs\joomla_1\administrator\components\com_hikashop\classes\shipping.php on line 394" is displayed. I need to have two methods in $usable_methods and no Notice. Any help would be appreciated.

An obvious solution would be to add a new shipping method of the "pluginName" type from the admin panel and everything would be ok. However this doesn't work for me.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODg3NjI3LXNoaXBwaW5nLXBsdWdpbi11c2FibGUtbWV0aG9kcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

9 years 10 months ago [\#256020](#256020) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[Shipping Plugin $usable\_methods](/forum/28-shipping-methods/887627-shipping-plugin-usable-methods#256020 "I am developing a shipping plugin for hikashop. The plugin makes requests to an API to determine price and all other parameters.  I need to have two methods in $usable&#95;methods.  here is demo sample from my pluginName.php  after the second array&#95;push two shipping methods are displayed as expected. and also &quot;Notice: Undefined offset: 1 in C:&#92;Bitnami&#92;wampstack-5.6.27-0&#92;apache2&#92;htdocs&#92;joomla&#95;1&#92;administrator&#92;components&#92;com&#95;hikashop&#92;classes&#92;shipping.php on line 394&quot; is displayed. I need to have two methods in $usable&#95;methods and no Notice. Any help would be appreciated.  An obvious solution would be to add a new shipping method of the &quot;pluginName&quot; type from the admin panel and everything would be ok. However this doesn't work for me.")*

Hello,

Note that in production mode you'll have to disable your error reporting, so no notice will be shown on your website.

Also, you should probably how we developped existing shipping plugins like USPS/UPS/... and instead, add available shipping services like this : Code:

$usable_rates[$new_method-&gt;shipping_id] = $new_method;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODg3NjI3LXNoaXBwaW5nLXBsdWdpbi11c2FibGUtbWV0aG9kcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")**
- [![c0untfl0yd's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile") Topic Author
- [ Offline](/forum/user/46230-c0untfl0yd)

Less More

- Posts: 4
- Thank you received: 0
-
-

9 years 10 months ago -  9 years 10 months ago [\#256296](#256296) by [c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")  Replied by *[c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")* on topic *[Shipping Plugin $usable\_methods](/forum/28-shipping-methods/887627-shipping-plugin-usable-methods#256296 "I am developing a shipping plugin for hikashop. The plugin makes requests to an API to determine price and all other parameters.  I need to have two methods in $usable&#95;methods.  here is demo sample from my pluginName.php  after the second array&#95;push two shipping methods are displayed as expected. and also &quot;Notice: Undefined offset: 1 in C:&#92;Bitnami&#92;wampstack-5.6.27-0&#92;apache2&#92;htdocs&#92;joomla&#95;1&#92;administrator&#92;components&#92;com&#95;hikashop&#92;classes&#92;shipping.php on line 394&quot; is displayed. I need to have two methods in $usable&#95;methods and no Notice. Any help would be appreciated.  An obvious solution would be to add a new shipping method of the &quot;pluginName&quot; type from the admin panel and everything would be ok. However this doesn't work for me.")*

Thank you for your response. I have done what you have asked and moved to your naming conventions as follows: Code:

function onShippingDisplay(&amp;$order,&amp;$dbrates,&amp;$usable_rates,&amp;$messages)

, also i have changed the way I populate the $usable_rates array as follows: Code:

$usable_rates[$new_method-&gt;shipping_id] = $new_method;

I have also red the documentation at [ Hikashop Documentation](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#onShippingDisplay). However this doesn't resolve my issue, as I still need to display two shipping methods of the same type in my checkout process without having a duplicate shipping method in my "Administrator &gt;&gt; Components &gt;&gt; Hika Shop &gt;&gt; System &gt;&gt; Shipping Methods". While reading the UPS Plugin's code i think i need to use the shippingMethods(&amp;$method) funtion to diplay some kind of dropdown options, or i could use onShippingSave(&amp;$order,&amp;$methods,&amp;$shipping_id) function when the user selects his shipping method some kind of options are displayed, or I will need to implement warehouses. The reeson i need two visible methods or options for my shipping plugin is that the api i am calling has an option "Delivery to your door" or "Delivered to the closest Courier's office" and the prices for those options are different. Scince i am developing a plugin and not a single website i can't resolve the issue in any other way such as custom fields or the like.

Last edit: 9 years 10 months ago by [c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODg3NjI3LXNoaXBwaW5nLXBsdWdpbi11c2FibGUtbWV0aG9kcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

9 years 10 months ago -  9 years 10 months ago [\#256300](#256300) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[Shipping Plugin $usable\_methods](/forum/28-shipping-methods/887627-shipping-plugin-usable-methods#256300 "I am developing a shipping plugin for hikashop. The plugin makes requests to an API to determine price and all other parameters.  I need to have two methods in $usable&#95;methods.  here is demo sample from my pluginName.php  after the second array&#95;push two shipping methods are displayed as expected. and also &quot;Notice: Undefined offset: 1 in C:&#92;Bitnami&#92;wampstack-5.6.27-0&#92;apache2&#92;htdocs&#92;joomla&#95;1&#92;administrator&#92;components&#92;com&#95;hikashop&#92;classes&#92;shipping.php on line 394&quot; is displayed. I need to have two methods in $usable&#95;methods and no Notice. Any help would be appreciated.  An obvious solution would be to add a new shipping method of the &quot;pluginName&quot; type from the admin panel and everything would be ok. However this doesn't work for me.")*

Hello,

Then in that case you should create 2 services for your shipping method. In the UPS shipping plugin, these services are also defined through the "$ups_methods" variable.

> or I will need to implement warehouses.

Note that your shipping method will already support Warehouses by default without adding more code.

Last edit: 9 years 10 months ago by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODg3NjI3LXNoaXBwaW5nLXBsdWdpbi11c2FibGUtbWV0aG9kcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")**
- [![c0untfl0yd's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile") Topic Author
- [ Offline](/forum/user/46230-c0untfl0yd)

Less More

- Posts: 4
- Thank you received: 0
-
-

9 years 10 months ago [\#256415](#256415) by [c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")  Replied by *[c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")* on topic *[Shipping Plugin $usable\_methods](/forum/28-shipping-methods/887627-shipping-plugin-usable-methods#256415 "I am developing a shipping plugin for hikashop. The plugin makes requests to an API to determine price and all other parameters.  I need to have two methods in $usable&#95;methods.  here is demo sample from my pluginName.php  after the second array&#95;push two shipping methods are displayed as expected. and also &quot;Notice: Undefined offset: 1 in C:&#92;Bitnami&#92;wampstack-5.6.27-0&#92;apache2&#92;htdocs&#92;joomla&#95;1&#92;administrator&#92;components&#92;com&#95;hikashop&#92;classes&#92;shipping.php on line 394&quot; is displayed. I need to have two methods in $usable&#95;methods and no Notice. Any help would be appreciated.  An obvious solution would be to add a new shipping method of the &quot;pluginName&quot; type from the admin panel and everything would be ok. However this doesn't work for me.")*

Can you give me some sort of example of using the variable properly Code:

&lt;?php class plgHikaShopshippingpluginName extends hikashopShippingPlugin { var $pluginName_methods = array();

to work with, please? And how to add them perhaps.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODg3NjI3LXNoaXBwaW5nLXBsdWdpbi11c2FibGUtbWV0aG9kcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

9 years 10 months ago [\#256424](#256424) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[Shipping Plugin $usable\_methods](/forum/28-shipping-methods/887627-shipping-plugin-usable-methods#256424 "I am developing a shipping plugin for hikashop. The plugin makes requests to an API to determine price and all other parameters.  I need to have two methods in $usable&#95;methods.  here is demo sample from my pluginName.php  after the second array&#95;push two shipping methods are displayed as expected. and also &quot;Notice: Undefined offset: 1 in C:&#92;Bitnami&#92;wampstack-5.6.27-0&#92;apache2&#92;htdocs&#92;joomla&#95;1&#92;administrator&#92;components&#92;com&#95;hikashop&#92;classes&#92;shipping.php on line 394&quot; is displayed. I need to have two methods in $usable&#95;methods and no Notice. Any help would be appreciated.  An obvious solution would be to add a new shipping method of the &quot;pluginName&quot; type from the admin panel and everything would be ok. However this doesn't work for me.")*

Hello,

About which variable are you talking about ?

The best solution will probably be to directly check the code and replicate the structure of the AuPost2 shipping method.

Also, note that you can directly check the "Shipping API" section of the developer documentation :
[ www.hikashop.com/support/documentation/6...tation.html#shipping](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#shipping)

The following user(s) said Thank You: [c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODg3NjI3LXNoaXBwaW5nLXBsdWdpbi11c2FibGUtbWV0aG9kcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")**
- [![c0untfl0yd's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile") Topic Author
- [ Offline](/forum/user/46230-c0untfl0yd)

Less More

- Posts: 4
- Thank you received: 0
-
-

9 years 10 months ago [\#256553](#256553) by [c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")  Replied by *[c0untfl0yd](/forum/user/46230-c0untfl0yd "View c0untfl0yd's Profile")* on topic *[Shipping Plugin $usable\_methods](/forum/28-shipping-methods/887627-shipping-plugin-usable-methods#256553 "I am developing a shipping plugin for hikashop. The plugin makes requests to an API to determine price and all other parameters.  I need to have two methods in $usable&#95;methods.  here is demo sample from my pluginName.php  after the second array&#95;push two shipping methods are displayed as expected. and also &quot;Notice: Undefined offset: 1 in C:&#92;Bitnami&#92;wampstack-5.6.27-0&#92;apache2&#92;htdocs&#92;joomla&#95;1&#92;administrator&#92;components&#92;com&#95;hikashop&#92;classes&#92;shipping.php on line 394&quot; is displayed. I need to have two methods in $usable&#95;methods and no Notice. Any help would be appreciated.  An obvious solution would be to add a new shipping method of the &quot;pluginName&quot; type from the admin panel and everything would be ok. However this doesn't work for me.")*

I am happy to inform you I have resolved my problem by first cloning the object and then pushing it to the usable rates array. The issue has to do with all object oriented languages not just php, and how objects are stored in the computer's ram. Thank you for your attention and support. ![:)](/media/kunena/emoticons/8.png ":)")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvODg3NjI3LXNoaXBwaW5nLXBsdWdpbi11c2FibGUtbWV0aG9kcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.300 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
