- Posts: 100
- Thank you received: 1
Using a custom field in a variant product
- paddyrolls
-
Topic Author
- Offline
Less
More
13 years 6 months ago #94857
by paddyrolls
Using a custom field in a variant product was created by paddyrolls
HI
I have the following setup
1 main product, 1 option and 2 variants.
I have created a custom field (called maximum_place) and assigned it to the Main Product. I would like to display this custom field in the variant drop down combo.
I can't seem to figure out how to reference this field in the view product and file option.php.
I have tried
$optionElement->maximum_place and $optionElement->main->maximum_place but i get nothing...
Have i called it correctly.
Thanks
Patrick
I have the following setup
1 main product, 1 option and 2 variants.
I have created a custom field (called maximum_place) and assigned it to the Main Product. I would like to display this custom field in the variant drop down combo.
I can't seem to figure out how to reference this field in the view product and file option.php.
I have tried
$optionElement->maximum_place and $optionElement->main->maximum_place but i get nothing...
Have i called it correctly.
Thanks
Patrick
Please Log in or Create an account to join the conversation.
13 years 6 months ago #95021
by nicolas
Replied by nicolas on topic Using a custom field in a variant product
Hi,
If you want to have the value of custom field in the main product of the option, it should indeed be $optionElement->maximum_place or $optionElement->main->maximum_place but only inside the foreach($this->element->options as $optionElement){ block of code in the option.php file.
Outside that block is will be more complex.
Something like that:
$optionElement = reset($this->element->options);
echo $optionElement->main->maximum_place;
If you want to have the value of custom field in the main product of the option, it should indeed be $optionElement->maximum_place or $optionElement->main->maximum_place but only inside the foreach($this->element->options as $optionElement){ block of code in the option.php file.
Outside that block is will be more complex.
Something like that:
$optionElement = reset($this->element->options);
echo $optionElement->main->maximum_place;
Please Log in or Create an account to join the conversation.
- paddyrolls
-
Topic Author
- Offline
Less
More
- Posts: 100
- Thank you received: 1
13 years 6 months ago - 13 years 6 months ago #95031
by paddyrolls
Replied by paddyrolls on topic Using a custom field in a variant product
HI Nicolas
I have used the following in the option.php file below line 86
$this->row->prices = array($variant->prices[$k]);
$optionElement = reset($this->element->options);
$text = $variant->start_date.$text;
$text.=" Remaining Spots " . $variant->product_quantity. " of " . $optionElement->main->maximum_place . ' '.($positive?'+':'').strip_tags($this->loadTemplate());
However, I still don't get the value which has been set in the custom field in the Main product.
Am I still doing something incorrect.
Thanks
Patrick
I have used the following in the option.php file below line 86
$this->row->prices = array($variant->prices[$k]);
$optionElement = reset($this->element->options);
$text = $variant->start_date.$text;
$text.=" Remaining Spots " . $variant->product_quantity. " of " . $optionElement->main->maximum_place . ' '.($positive?'+':'').strip_tags($this->loadTemplate());
However, I still don't get the value which has been set in the custom field in the Main product.
Am I still doing something incorrect.
Thanks
Patrick
Last edit: 13 years 6 months ago by paddyrolls.
Please Log in or Create an account to join the conversation.
13 years 6 months ago #95054
by nicolas
Replied by nicolas on topic Using a custom field in a variant product
Is the value in the main product or in the option ?
If it's in the main product it should be either $this->element->maximum_place or $this->element->main->maximum_place
If it's in the main product it should be either $this->element->maximum_place or $this->element->main->maximum_place
Please Log in or Create an account to join the conversation.
- paddyrolls
-
Topic Author
- Offline
Less
More
- Posts: 100
- Thank you received: 1
13 years 6 months ago #95245
by paddyrolls
Replied by paddyrolls on topic Using a custom field in a variant product
HI Nicolas
Thank you for the information
The custom field was on the main product so $this->element->maximum_place worked.
Thank you for the information
The custom field was on the main product so $this->element->maximum_place worked.
Please Log in or Create an account to join the conversation.
Time to create page: 0.184 seconds