Adding clear cart button to the showcart view

  • Posts: 26
  • Thank you received: 0
8 years 6 months ago #240701

-- HikaShop version -- : 2.6.4

Hi ,
I am using showcart view in a pop up window.
I want to add a button (same as proceed to checkout) that clears the cart contents, I tried to add it like the (proceed to checkout) button ,although it's indeed clearing the cart but it is changing the contents of the pop up window, I want it to close the window(just like the proceed to checkout button does) and redirects the main browser page to the listing page
here's the code I am using

$clear_url=hikashop::completeLink('product&task=cleancart',false,true);
echo $this->cart->displayButton('Clear Cart','clearcart',$this->params, $clear_url,'window.location=\''.$clear_url.'\'; return false;');

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
8 years 6 months ago #240755

Hi,

Then, instead of:

$clear_url=hikashop::completeLink('product&task=cleancart',false,true);
echo $this->cart->displayButton('Clear Cart','clearcart',$this->params, $clear_url,'window.location=\''.$clear_url.'\'; return false;');
you want to do:
$clear_url=hikashop::completeLink('product&task=cleancart',false,true);
echo $this->cart->displayButton('Clear Cart','clearcart',$this->params, $clear_url,'window.parent.location=\''.$clear_url.'\'; return false;');

The following user(s) said Thank You: issa.mouawad

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

  • Posts: 26
  • Thank you received: 0
8 years 6 months ago #240767

I must say, the integration with iframe pop up of joomla is seamless and handy ,
I have worked out the "choose options" to work inside a pop up too , but faced couple issues,
1- I figured out how to create a hyper link that shows the choose options view in a popup , but I would like to use the same standard button (via displayButton helper method) to create the same behavior , so how to pass the needed parameters to the displayButton? (like class = modal and the other parameters)
following is the code I used to display it in hyperlink

<a class="modal" rel="{handler: 'iframe', size: {x: 760, y: 480}}" href="<?php echo hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$url_itemid.$this->category_pathway,$this->row ,true);?>" > Choose Options</a>
2- within the popup when the user clicks "add to cart" , a popup is displayed within the choose options pop up (with two buttons procceed to checkout or contiune shopping) it's very confusing, I want a more logical flow , like for example closing the popup and displaying the "ask_user" popup in the parent, or just closing the popup and refreshing the page, anything logical more than nested popup can work for me

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
8 years 6 months ago #240768

Hi,

1. A button uses the input HTML tag. The modal system of Joomla only supports links.
So I don't recommend to use the displayButton function. Instead, just add CSS code so that your a tag looks like a button.
Normally, if you add the button and/or the hikashop_cart_button classes to the a tag it should display like a button:

<a class="modal hikashop_cart_button button" rel="{handler: 'iframe', size: {x: 760, y: 480}}" href="<?php echo hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.'&name='.$this->row->alias.$url_itemid.$this->category_pathway,$this->row ,true);?>" > Choose Options</a>

2. Mmm, I guess that you'll have to edit the file "quantity" and add custom javascript to the displayButton call displaying the add to cart button so that you can close the popup after the add to cart or something like that.
You can use such js to close a popup:
window.top.hikashop.closeBox();
or:
window.parent.hikashop.closeBox();
or:
window.hikashop.closeBox();

based on which popup you want to close where.

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

  • Posts: 26
  • Thank you received: 0
8 years 6 months ago #240804

Hi
thanks it works fine now,
for the display of the link , I actually need to put the link in an article too, but it's not opening the popup , instead it's is opening a new page,
how to solve this issue in joomla ? I checked with firebug, I am getting exactly the same html of the link, but it works in product listing and doesn't work in article
I searched a little, I found solutions to enable iframes in articles, but couldn't find these options in my back end, beside I think they are talking about embedding iframe inside joomla article not with a hyperlink.
I know it's not really related to hikashop , but I appreciate if you can give me a hit on that

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
8 years 6 months ago #240807

Hi,

You need to run that PHP code to load the mootools modal system on these pages:
JHTML::_(‘behavior.modal’);

So you can for example add that at the beginning of the index.php of your template.

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

Time to create page: 0.064 seconds
Powered by Kunena Forum