- Posts: 42
- Thank you received: 0
Can i change the custom field data type to numeric
10 years 8 months ago #228080
by hexcodc
Can i change the custom field data type to numeric was created by hexcodc
-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.8.4
-- PHP version -- : 5.5.30
Hi, I have a question. is there a way I can create a custom field type currently TEXT to numeric so I can add the numbers up. I know that I can change it directly through the database, if it is the only way to do so, which tables should I update assuming I am working on the product table.
Thanks,
Gary
-- Joomla version -- : 3.8.4
-- PHP version -- : 5.5.30
Hi, I have a question. is there a way I can create a custom field type currently TEXT to numeric so I can add the numbers up. I know that I can change it directly through the database, if it is the only way to do so, which tables should I update assuming I am working on the product table.
Thanks,
Gary
Please Log in or Create an account to join the conversation.
10 years 8 months ago #228081
by hexcodc
Replied by hexcodc on topic Can i change the custom field data type to numeric
The reason I want is that I want to show travel points for each product using the custom field, each product has different points. I want to have the total points added up and shown to the user during checkout. Can alphauserpoints do the tricks?
Please Log in or Create an account to join the conversation.
10 years 8 months ago #228091
by nicolas
Replied by nicolas on topic Can i change the custom field data type to numeric
Hi,
No, AUP won't help you.
You need to create a custom field of the type "product" via the menu Display>Custom field.
That will allow you to enter the points for each product in the product edition page of the backend (or in the database).
Then, to display the total of the points of the products in the cart on the checkout, you'll have to customize the file "cart" of the view "checkout" via the menu Display>Views in order to add custom code to do the sum and then display it there.
No, AUP won't help you.
You need to create a custom field of the type "product" via the menu Display>Custom field.
That will allow you to enter the points for each product in the product edition page of the backend (or in the database).
Then, to display the total of the points of the products in the cart on the checkout, you'll have to customize the file "cart" of the view "checkout" via the menu Display>Views in order to add custom code to do the sum and then display it there.
Please Log in or Create an account to join the conversation.
10 years 8 months ago #228224
by hexcodc
Replied by hexcodc on topic Can i change the custom field data type to numeric
Thank you, can you show me the code to display product custom field on checkout?
Please Log in or Create an account to join the conversation.
10 years 8 months ago #228237
by nicolas
Replied by nicolas on topic Can i change the custom field data type to numeric
Hi,
Well, in the cart file of the checkout view, you can use such code:
echo $row->field_column_name;
where field_column_name is to be replaced with the column name of the custom field.
Well, in the cart file of the checkout view, you can use such code:
echo $row->field_column_name;
where field_column_name is to be replaced with the column name of the custom field.
Please Log in or Create an account to join the conversation.
10 years 8 months ago #228817
by hexcodc
Replied by hexcodc on topic Can i change the custom field data type to numeric
Hi Nicolas,
Thank you for your reply. I have managed to create a custom field (travel point) for the item table as the picture attachment. Now my question is that can you show me the code so that i can add the points together and display the total in the checkout.
Product1 (points x quality) + Product2 (points x qualty) = Total Points
Regards,
Gary
Thank you for your reply. I have managed to create a custom field (travel point) for the item table as the picture attachment. Now my question is that can you show me the code so that i can add the points together and display the total in the checkout.
Product1 (points x quality) + Product2 (points x qualty) = Total Points
Regards,
Gary
Please Log in or Create an account to join the conversation.
10 years 8 months ago - 10 years 8 months ago #228824
by nicolas
Replied by nicolas on topic Can i change the custom field data type to numeric
Hi,
Well, there is nothing complex:
Before the foreach displaying each product in the cart view file:
$total_points = 0;
Then, in the foreach:
$total_points+= $row->travel_points*$row->cart_product_quantity;
And after the foreach:
echo $total_points;
Well, there is nothing complex:
Before the foreach displaying each product in the cart view file:
$total_points = 0;
Then, in the foreach:
$total_points+= $row->travel_points*$row->cart_product_quantity;
And after the foreach:
echo $total_points;
Last edit: 10 years 8 months ago by nicolas.
Please Log in or Create an account to join the conversation.
10 years 8 months ago #229073
by hexcodc
Replied by hexcodc on topic Can i change the custom field data type to numeric
thank you
Please Log in or Create an account to join the conversation.
Time to create page: 0.194 seconds