- Posts: 156
- Thank you received: 0
How to trigger add $10 from radio selection?part2
$already = false;
foreach($this->rows as $i => $row){
if($row->product_code =='Transfer_Number_Fee') $already = true;
}
if($this->order->numberchoice){
if(!$already){
$app =& JFactory::getApplication();
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=9&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=9&quantity=0&add=1&return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}
Please Log in or Create an account to join the conversation.
Instead of:
if($this->order->numberchoice){
you should have:
if($this->order->numberchoice=='newnumber'){
Please Log in or Create an account to join the conversation.
foreach($this->rows as $i => $row){
if($row->product_code =='Transfer_Number_Fee') $already = true;
}
if($this->order->numberchoice=='keepnumber'){
if(!$already){
$app =& JFactory::getApplication();
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=9&quantity=1&add=0&return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}else{
if($this->order->numberchoice=='newnumber'){
$app =& JFactory::getApplication();
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=9&quantity=0&add=1&return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}
This is what i have now. it's not doing anything.
Please Log in or Create an account to join the conversation.
$already = false;
foreach($this->rows as $i => $row){
if($row->product_code =='Transfer_Number_Fee') $already = true;
}
if($this->order->numberchoice=='newnumber'){
if(!$already){
$app =& JFactory::getApplication();
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=9&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=9&quantity=0&add=1&return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}
Please Log in or Create an account to join the conversation.
i don't think this is going to give me the result i want. the code says if they select they want a new number and there isn't a transfer fee there it will add one. I want the transfer fee to come up when they select that they want to keep their number, so it would be 'keepnumber' instead of 'newnumber'. also based on the code you sent me wouldn't it get stuck in a loop? adding and removing the product? if the selection was left on 'newnumber'.
so over all what we want is that if the selection is 'keepnumber' to add the transfer fee to the cart, and if they select 'newnumber' it gets removed. That is why i thought this might work.
it's not doing anything at the moment. just thought it might need some tweaking to make it work. also since this on the custom field part should i add the code there or in the cart view? also since it's in the custom fields part should we add the a check for the user selection like we had in the code for the custom fields?
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
your saying to change it to
cart_fields,login_address_terms,shipping_payment,confirm_address_cart_status,end
i don't want the fields to be under the cart. i would like them to be as they are now. what can i do to the code above to make it work like that.
Please Log in or Create an account to join the conversation.
$app =& JFactory::getApplication();
$order = $app->getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null);
$fieldsClass = hikashop_get('class.field');
$this->order = $fieldsClass->getFields('frontcomp',$order,'order');
That will initialize the custom fields data on the cart view.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Fatal error: Call to undefined function hikashop_get() in /home/iqcellul/public_html/templates/ja_anion/html/com_hikashop/checkout/cart.php on line 234
This is the whole code right now
$app =& JFactory::getApplication();
$order = $app->getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null);
$fieldsClass = hikashop_get('class.field');
$this->order = $fieldsClass->getFields('frontcomp',$order,'order');
$already = false;
foreach($this->rows as $i => $row){
if($row->product_code =='Transfer_Number_Fee') $already = true;
}
if($this->order->numberchoice=='keepnumber'){
if(!$already){
$app =& JFactory::getApplication();
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=9&quantity=1&add=0&return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}else{
if($this->order->numberchoice=='newnumber'){
$app =& JFactory::getApplication();
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=9&quantity=0&add=1&return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
$app =& JFactory::getApplication();
$order = $app->getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null);
$fieldsClass = hikashop::get('class.field');
$this->order = $fieldsClass->getFields('frontcomp',$order,'order');
$already = false;
foreach($this->rows as $i => $row){
if($row->product_code =='Transfer_Number_Fee') $already = true;
}
if($this->order->numberchoice=='keepnumber'){
if(!$already){
$app =& JFactory::getApplication();
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=9&quantity=1&add=0&return='.urlencode(base64_encode(hikashop::currentUrl())),false,true));
}
}else{
if($this->order->numberchoice=='newnumber'){
$app =& JFactory::getApplication();
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=9&quantity=0&add=1&return='.urlencode(base64_encode(hikashop::currentUrl())),false,true));
}
}
i tried it with and without the false,true
Please Log in or Create an account to join the conversation.
That code seems correct. You should put some traces to make sure that the $already has the correct value before the if and that the $this->order variable contains the numberchoice custom field value.
Please Log in or Create an account to join the conversation.
$order = $app->getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null);
$fieldsClass = hikashop::get('class.field');
$this->order = $fieldsClass->getFields('frontcomp',$order,'order');
cause i used firephp to echo the value of $this->order->numberchoice and in the cart view i get null , but in the fields view i get the correct value. so it's something to do with the code above and bring in the data from the order table.
Please Log in or Create an account to join the conversation.
i removed
Please Log in or Create an account to join the conversation.
$fieldsClass = hikashop::get('class.field');
$this->order = $fieldsClass->getFields('frontcomp',$order,'order');
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.