Product Custom Fields

  • Posts: 93
  • Thank you received: 3
11 years 2 months ago #160746

-- url of the page with the problem -- : mywebsite.com/mypage
-- HikaShop version -- : 2.3.1
-- Joomla version -- : 3.3
-- PHP version -- : x.x.x
-- Browser(s) name and version -- : XXXXX x.x.x
-- Error-message(debug-mod must be tuned on) -- : Error_message

Hi,
I have 2 questions n trying to find a stock solution for my customer.

1. how can I get the product custom fields to print on the shipping invoice under the product so it looks like a bill or materials
2. how on the same thing and possibly on the product screen (but not so important) can I multiply the number in the product custom field by the qty ordered to give a total of that custom field.

For Example Product A has custom fields Back Board with value 2 and Sides with value 4

The shipping invoice needs to show:
Product A qty 2
Consits of Backboard 4 (quantity * 2)
Sides 8 (quantity * 2)


Any help

Thanks

Tony

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

  • Posts: 12953
  • Thank you received: 1778
11 years 2 months ago #160752

Hello Tony,

1. The solution will be to directly edit the code of the "invoice" file of the "order" view of your back-end template.

2. Note that, also by editing your the "invoice" file you'll probably be able to display your custom field value like : Sides 8 (quantity * 2)

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

  • Posts: 93
  • Thank you received: 3
11 years 2 months ago #160899

Thanks,
Any idea which block of code i would need to take from the product page. To add to the invoice to do this and how i would run calculations on these fields based on the quantity of product ordered

Thanks

Tony

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

  • Posts: 12953
  • Thank you received: 1778
11 years 2 months ago #160915

Hello Tony,
It will depend of how you configured your custom field, but if it's a "product" custom field, you'll just have to use this kind of PHP code :

<?php echo $product->YOUR_CUSTOM_FIELD_NAME;?>
Inside that foreach loop :
 foreach($this->order->products as $product){

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

  • Posts: 93
  • Thank you received: 3
11 years 2 months ago #163311

Hi Mohamed,
I think I have nearly go this all sorted however $product dosent load the correct custom fields unless I am doing something wrong.

I have a product that has 4 characteristics. In the main product there are 6 custom fields filled in with say 1 2 3 4 5 6

in the characteristics the only difference is that say field 2 rather that having 2 in has 4 so all fields are blank except firld 2 which contains 4.

This works fine on product listing page as it somehow merges the root product and the characteristic to give 1 4 3 4 5 6

put $product in invoice view only contains the fields for the characteristic version, how can I can the root product fields as well?

Thanks

Tony

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

  • Posts: 84300
  • Thank you received: 13697
  • MODERATOR
11 years 2 months ago #163466

Hi,

Yes, products/variants values are not merged for the order products since it is not necessary for the default displays.
You'll have to use such code to load that yourself:

$productClass = hikashop_get('class.product');
$mainProduct = $productClass->get($product->product_parent_id);
echo $mainProduct->YOUR_CUSTOM_FIELD_NAME;

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

Time to create page: 0.062 seconds
Powered by Kunena Forum