fill custom field with shipping method

  • Posts: 585
  • Thank you received: 23
  • Hikaserial Subscription Hikashop Multisite
2 years 11 months ago #338111

Hi,

My customer like to have a new column "shipping methode" in the back-end orders list.
So it's easier to see which packages are being picked up and which need to be shipped without having to open the order every time.

So I create a custom field en show it in the back-end list. That works fine.

But now I would like to fill this custom field with the Mass Action OPERATION
But I only see only "manual" as result. See screenshot below.
Can you please help me how I can show the shipping_name here?

It looks like it has something to do with a combination from order_shipping_id and
order_shipping_method but I don't know how to do this.



Hope you can help me,
Kind regards,
Lumiga


Kind regards,
Lumiga
Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 11 months ago #338113

Hi,

order_shipping_method only contains the folder name of the shipping plugin.
If you created shipping methods for the "HikaShop manual shipping methods plugin" then it's normal that you only see "manual" in there.
order_shippping_id contains the id of the shipping method.
The name of the shipping method is not stored in the order.
It is only available in the hikashop_shipping table, in the shipping_name column.
That information is not available in the listing of the orders.

What you can do in your mass action is to use an action "run mysql query" and use that query:

UPDATE #__hikashop_order SET verzendmethode = (SELECT shipping_name FROM #__hikashop_shipping WHERE shipping_id = {order_shipping_id}) WHERE order_id={order_id};

Note however that this won't work by ideal for dynamic shipping methods like UPS, USPS or FedEx as the name of the shipping method doesn't contain the shipping service (standard, express, international, etc). For these shipping methods, it would require some PHP code to be written to request the complete shipping method information to the shipping plugin. It would require some proper development.

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

  • Posts: 585
  • Thank you received: 23
  • Hikaserial Subscription Hikashop Multisite
2 years 11 months ago #338127

Thanks Nicolas,

With my databse table prefix the query looks like this:

UPDATE msw73_hikashop_order SET verzendmethode = (SELECT shipping_name FROM msw73_hikashop_shipping WHERE shipping_id = {order_shipping_id}) WHERE order_id={order_id};

But we get this error when we use it:
1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') WHERE order_id=89' at line 1

Am I doing something wrong or do I need to change something in the Query?

Hope you can help me ;-)

Kind regards,
Lumiga


Kind regards,
Lumiga
Attachments:
Last edit: 2 years 11 months ago by Lumiga.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 11 months ago #338136

Hi,

You must have run the mass action on all the orders and you must have some orders without a shipping method, and thus the query fails.
Add a filter on your mass action on the order column "order_shipping_id" being "not empty".

Also, it could be because you have HikaMarket / warehouses. In that case, the order_shipping_id won't contain just the id of the shipping method but also the vendor id / warehouse id and it cpould even be several shipping method ids (since you can select several shipping methods, one per group of products).
In that case, it would be more complex to fill the shipping name as it would have to be processed with PHP.
However, a simple way to discard these orders and only focus on the simple orders is to change the query to:

UPDATE #__hikashop_order SET verzendmethode = (SELECT shipping_name FROM #__hikashop_shipping WHERE shipping_id = '{order_shipping_id}') WHERE order_id={order_id};

The following user(s) said Thank You: Lumiga

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

  • Posts: 585
  • Thank you received: 23
  • Hikaserial Subscription Hikashop Multisite
2 years 11 months ago #338148

Thank you very much, I am very happy with it. Wishing you all happy holidays.


Kind regards,
Lumiga
The following user(s) said Thank You: nicolas

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

Time to create page: 0.075 seconds
Powered by Kunena Forum