- Posts: 11
- Thank you received: 0
How to use custom fields to modify quantity field
I have created a file in my template folder that overrides the default behaviour with a dropdown box containing options for fixed quantities of 50,100,150,200 ... and this works fine. But I would like to create a product custom field that defines what the incremental values would be.
If the value is for example,qty_range = "50;100;150;200", then the input would be a dropdown containing those values.
If the value is 0 or blank, it would default to a normal (ajax) input field.
Can I access the custom field from within the templates/TEMPLATE/html/hikashop_button.php ?
Please Log in or Create an account to join the conversation.
$productClass = hikashop_get('class.product');
$product = $productClass->get(JRequest::getInt('cid'));
echo $product->CUSTOM_FIELD_COLUMN_NAME;
where CUSTOM_FIELD_COLUMN_NAME is the column name of your custom field.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
nicolas wrote: If your quantity field is displayed on product pages (not on listings) then you can retrieve the custom field like that:
$productClass = hikashop_get('class.product');
$product = $productClass->get(JRequest::getInt('cid'));
echo $product->CUSTOM_FIELD_COLUMN_NAME;
where CUSTOM_FIELD_COLUMN_NAME is the column name of your custom field.
When you do it like this, does the system actually use the number from the custom field as if it was input in the normal input box? For instance, if I create a custom drop down with exact predetermined quantities, will it treat the value of the selected drop down (if it's a number) as normal (that way it will calculate the weight for shipping and the total cost and all that)? To put it in programmer terminology, will it populate the quantity field for the cart DB table with the value of the custom field (again, obviously only if the value of the custom field selection is a number or integer or whatever)?
Please Log in or Create an account to join the conversation.
www.hikashop.com/forum/4-how-to/15254-re...uantity-ordered.html
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
nicolas wrote: If your quantity field is displayed on product pages (not on listings) then you can retrieve the custom field like that:
$productClass = hikashop_get('class.product');
$product = $productClass->get(JRequest::getInt('cid'));
echo $product->CUSTOM_FIELD_COLUMN_NAME;
where CUSTOM_FIELD_COLUMN_NAME is the column name of your custom field.
It seems to me like you should only have to add on like one more line of code on to this ^^^ code to tell it to retrieve the value for the selected drop down choice and assign it to the quantity variable -> then add that value to the quantity column in the DB when you click on the button.
Please Log in or Create an account to join the conversation.
www.hikashop.com/support/support/documen...tation.html#override
You can see an example of such plugin here:
demo.hikashop.com/index.php?option=com_h...ct&task=show&cid=214
Please Log in or Create an account to join the conversation.