- Posts: 156
- Thank you received: 0
How to trigger add $10 from radio selection?
15 years 3 months ago #17833
by Rickhavoc
How to trigger add $10 from radio selection? was created by Rickhavoc
How to trigger add $10 from radio selection?
I have a custom field "radio" in my check out page. i want to be able to add $10 to this if it's not null or false. would the simplest way be to just add some PHP code to a file somewhere to add $10 to the shopping cart?
i have most figured out but what code would i need to just add $10 extra if radio box was true on checkout page?
I have a custom field "radio" in my check out page. i want to be able to add $10 to this if it's not null or false. would the simplest way be to just add some PHP code to a file somewhere to add $10 to the shopping cart?
i have most figured out but what code would i need to just add $10 extra if radio box was true on checkout page?
Please Log in or Create an account to join the conversation.
15 years 3 months ago #17843
by nicolas
Replied by nicolas on topic Re: How to trigger add $10 from radio selection?
You would have to edit the file cart of the view checkout via the menu Display->Views.
There, you could add something like that:
supposing that the 10 dollars product has the id 106 and the product code 10_dollars_product and that your custom order field has the column name custom_field_column_name
There, you could add something like that:
Code:
$already = false;
foreach($this->rows as $i => $row){
if($row->product_code =='10_dollars_product') $already = true;
}
if($this->order->custom_field_column_name){
if(!$already){
$app =& JFactory::getApplication();
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=106&quantity=1&add=0&return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}else{
if($already){
$app =& JFactory::getApplication();
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=106&quantity=0&add=0&return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}
Please Log in or Create an account to join the conversation.
15 years 3 months ago - 15 years 3 months ago #17856
by Rickhavoc
Replied by Rickhavoc on topic Re: How to trigger add $10 from radio selection?
Why then use of the if else? can you explain the code more if you can? i just want to understand for future resources.. thanks..
Last edit: 15 years 3 months ago by Rickhavoc.
Please Log in or Create an account to join the conversation.
15 years 3 months ago #17869
by nicolas
Replied by nicolas on topic Re: How to trigger add $10 from radio selection?
As you can see, in the if, the redirect url has a quantity of 1, which means that it adds the product 106 to the cart.
In the else, it has a quantity of 0, which means that it removes the product 106 from the cart.
So if the user changes his mind and toggle several times your custom field of the table order, the $10 product will be added or removed based on the user's change.
In the else, it has a quantity of 0, which means that it removes the product 106 from the cart.
So if the user changes his mind and toggle several times your custom field of the table order, the $10 product will be added or removed based on the user's change.
Please Log in or Create an account to join the conversation.
15 years 3 months ago #18893
by Rickhavoc
Replied by Rickhavoc on topic Re: How to trigger add $10 from radio selection?
i now have the radio selection in my field step of checkout do i add this code there instead?
Please Log in or Create an account to join the conversation.
15 years 3 months ago #18895
by nicolas
Replied by nicolas on topic Re: How to trigger add $10 from radio selection?
Why instead ?
You need to add it yes but you need to keep the code of the custom fields... Otherwise, you won't see your custom fields...
You need to add it yes but you need to keep the code of the custom fields... Otherwise, you won't see your custom fields...
Please Log in or Create an account to join the conversation.
15 years 3 months ago #19003
by Rickhavoc
Replied by Rickhavoc on topic Re: How to trigger add $10 from radio selection?
the Radio selection field is now in the fields step of check out, i will be putting the custom fields differently using the code you gave me on the other post about echoing each field separately.
so this code
do i add it to the view field of checkout? or which one?
so this code
Code:
$already = false;
foreach($this->rows as $i => $row){
if($row->product_code =='10_dollars_product') $already = true;
}
if($this->order->custom_field_column_name){
if(!$already){
$app =& JFactory::getApplication();
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=106&quantity=1&add=0&return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}else{
if($already){
$app =& JFactory::getApplication();
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=106&quantity=0&add=0&return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}
do i add it to the view field of checkout? or which one?
Please Log in or Create an account to join the conversation.
15 years 3 months ago #19024
by nicolas
Replied by nicolas on topic Re: How to trigger add $10 from radio selection?
That code uses mainly the data of the products in the cart, so I would put it in the cart file of the view checkout.
Please Log in or Create an account to join the conversation.
Time to create page: 0.198 seconds