Transfer product category to order items

  • Posts: 16
  • Thank you received: 1
10 years 8 months ago #184292

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.4.35
-- Browser(s) name and version -- : Firefox 34.0.5

For my client it is important to show the category from which the items were ordered (during the making of the wishlist or shopping cart). My client wants to retrace the path of the ordering process. That's why I want to add a field for every order item in which that category is listed.

Therefore I thought to add a custom field 'item' via your custom fields menu, or add a table column myself in table 'order_product' or 'cart_product. I think ordering in this case only may be possible from the category list (not from product details, because the category is lost over there) called from the menu list / div.
Maybe I should make an override for <listing_div.php>, but at least for <add_to_cart_listing.php>, I think.

But how to do this? How to transfer the (sub)category which is shown, to the new database field, at the moment of ordering. And what is the best information to transfer? Perhaps the title (page title) and may be the url, but otherwise the category ID (but than i hav to translate this later on to a category name in the order).

For the URL I need in <add_to_cart_listing.php> something like:

<?php echo hikashop_currentURL(); ?>

TIA for any help,
Joris

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

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 8 months ago #184359

Hi,

There is no need to add anything in the database.
In the hikashop_cart_product and the hikashop_order_product tables, you have the product_id column where is stored the product id of each product of the cart/order.
So just do a query on the table hikashop_product_category to get the list of categories of each product, and then another one in the hikashop_category table to load the data from each category and you'll be able to display the category name next to each product on the cart and order products listing.

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

  • Posts: 16
  • Thank you received: 1
10 years 8 months ago #184372

Thank you, Nicolas. But most of the products are in multiple categories (sometimes over 20). And we just want to show the category from which the items were ordered (during the making of the wishlist or shopping cart).

So someone orders a component (product) for a Mercedes Vito (one of the categories). You can buy this component for many other cars (other categories, but not all). But in the order/wishlist I want to see that the client selected the (category) Mercedes Vito (or other car) before clicking the Add to cart button. So I want to know his order path. In that way, we can assure the client buys only correct products, without mistakes.

I hope you can help me to solve this problem.

Kind regards,
merry christmas,
Joris

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

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 8 months ago #184382

Hi,

In that case, make sure that the "simplified breadcrumb" option is turned off in the hikashop configuration and create a custom field of the table "item" and the type "text" and the column name "category_pathway".
Then, you can just hide that custom field with some simple CSS where needed.
That custom field will be available in both tables order_product and cart_product with the id of the category from which the user is coming for each product and you'll just have to do one query to load the category name for that id in order to display it in your cart/order products listings.

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

  • Posts: 16
  • Thank you received: 1
10 years 8 months ago #184427

Hi Nicolas,

That sounds hopefull. But after following your instructions, there is no catgerory id in the tables added.

Simplified breadcrumb is turned off now.
I created a custom field as you said. The config is presented in the first screenshot. Of course I have tried some other settings too.
For testing purpose I do not hide anything at this moment.
In the database I can see the new table column "category_pathway" in both tables.
But in the List-Div view (shown in the second screenshot), you see the value of this new custom field is nothing more than "category_pathway".
After adding to cart, the table fields "category_pathway" stay NULL.

In the view files (list and add) I do not see any declaration of the category pathway, so I do not understand where to look for better results. Any idea what I am missing or doing wrong?

Thanks again.

Attachments:
Last edit: 10 years 8 months ago by Joris. Reason: no large images

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

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 8 months ago #184428

Hi,

The category_pathway is a parameter which is added to the product page link on the products listing in order to display the full breadcrumb on the product page. It contains the id of the category from which the user is coming before reaching the product page.
And the custom item fields will automatically use the value of a parameter in the URL if it has the same name as their column name, which would be the case here.
You don't see it because you're displaying your custom item field on the products listing page, not on the product page, which I wasn't expecting.
In that case, try to create a custom item field with the column "cid" which is the name of the category id parameter on the products listing pages and you should be able to achieve the same result but on the products listing (and you can see the "simplified breadcrumb" option to whatever you want in that case.

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

  • Posts: 16
  • Thank you received: 1
10 years 8 months ago #184636

Strange, but this transfers the product id... (not category id).
And I need to make use of the product detail page first.

Is there any other parameter I can use to transfer the category id when submitting the order button in the list/div view (products in category)?
Or otherwise the page url and page title, at the moment of ordering (from the product in categerory view)?

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

Time to create page: 0.062 seconds
Powered by Kunena Forum