custom field with price

  • Posts: 26
  • Thank you received: 1
8 years 1 week ago #255230

-- HikaShop version -- : HikaShop Business 2.6.4
-- Joomla version -- : 3.6.4
-- PHP version -- : 5.6.26
-- Browser(s) name and version -- : Chrome newest

Hi,

Question 1

I need the customer to be able to choose a packing: normal, luxe etc. Each packing has it's own price. I dont want to use the Characteristics because this will result in to many variations. I've created a custom dropdown field to achieve this option. This custom field is using the donation plugin of hikashop to calculate the new price for each product. This plugin comes with the following problem: the plugin uses the option value, when someone changes the value in the html, this value wil be used. The customer can easily "hack" the packing dropdown is this way. Is there a way to secure this?

Question 2

For one product i want te customer to select the quantity 1 or a minimum of 10. So 2 - 9 have to be disabled. Is there a proper way to achieve this?

Question 3

When a customer selects quantity 1 the customer has to be restricted to the deluxe packing. For quantity 10 or higher the customer can select every packing method. Is it possible to have related dropdown selections?

I'm sorry for this many questions.

I'm looking forward to the answers!

Thanks!!

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

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 1 week ago #255269

Hi,

1. If you know a bit of PHP it's easy to change the plugin to avoid that.
For example, instead of directly using the value like the plugin does now with the code:

switch($taxes){
					case 2:
						$product->prices[$k]->price_value = $currencyClass->getUntaxedPrice(hikashop_toFloat($product->$column),hikashop_getZone(),$product->product_tax_id);
						$product->prices[$k]->taxes=$currencyClass->taxRates;
						$product->prices[$k]->price_value_with_tax = hikashop_toFloat($product->$column);
						break;
					case 1:
						$product->prices[$k]->price_value = hikashop_toFloat($product->$column);
						$product->prices[$k]->price_value_with_tax = $currencyClass->getTaxedPrice(hikashop_toFloat($product->$column),hikashop_getZone(),$product->product_tax_id);
						$product->prices[$k]->taxes=$currencyClass->taxRates;
						break;
					case 0:
					default:
						$product->prices[$k]->price_value = hikashop_toFloat($product->$column);
						$product->prices[$k]->price_value_with_tax = hikashop_toFloat($product->$column);
						break;
				}
, you could do it like that:
switch($product->$column){
					case 'first':
						$value = 18.99;
						break;
					case 'second':
					default:
						$value = 28.99;
						break;
				}
				switch($taxes){
					case 2:
						$product->prices[$k]->price_value = $currencyClass->getUntaxedPrice(hikashop_toFloat($value),hikashop_getZone(),$product->product_tax_id);
						$product->prices[$k]->taxes=$currencyClass->taxRates;
						$product->prices[$k]->price_value_with_tax = hikashop_toFloat($value);
						break;
					case 1:
						$product->prices[$k]->price_value = hikashop_toFloat($value);
						$product->prices[$k]->price_value_with_tax = $currencyClass->getTaxedPrice(hikashop_toFloat($value),hikashop_getZone(),$product->product_tax_id);
						$product->prices[$k]->taxes=$currencyClass->taxRates;
						break;
					case 0:
					default:
						$product->prices[$k]->price_value = hikashop_toFloat($value);
						$product->prices[$k]->price_value_with_tax = hikashop_toFloat($value);
						break;
				}
And thus, that would only allow the values "first" and "second" in the custom field for the override of the price of the product.

2. and 3. If the avalailable choices have to be tied to the quantity selected, I would recommend to also use a custom item field for the selection of the quantity (and turn off the display of the quantity input field in the HikaShop configuration) and use the "display limited to" setting of your custom fields in order to display different fields based on what is selected in the first one. Then, in your price override (donation) plugin, you can take the custom fields values and based on them, set the price you want for the product.

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

  • Posts: 26
  • Thank you received: 1
8 years 1 week ago #255275

Hi Nicolas,

Thanks for the response!

I actually dont want the hard coded price solution but if this is the most easy way to acomplish the wanted result i will do it this way.

Thanks!

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

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 1 week ago #255277

Hi,

You can always create custom product fields to enter the prices in the product and have the plugin uses these instead of hard coding them in the plugin.

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

Time to create page: 0.057 seconds
Powered by Kunena Forum