Ajax Add to cart

  • Posts: 3
  • Thank you received: 0
10 years 8 months ago #148096

I try to use the equivalent of the url below from the hikashop demo page (it does respond with the markup of the updated cart module so that it can be updated)
The problem is that in my testing site (not accessible from outside) the output of that page is just this:

<div id="system-message-container">
<div id="system-message">
</div>
</div>

I know something is right, using the debugger I can check that in the display() function from hikashopView (in components/com_hikashop/helpers/helper.php) the view of the module has been correctly rendered, but the output is finally another one!
function display($tpl = null) {

		$lang = JFactory::getLanguage();
		if($lang->isRTL()) $this->direction = 'rtl';

		if($this->triggerView) {
			JPluginHelper::importPlugin('hikashop');
			$dispatcher = JDispatcher::getInstance();
			$dispatcher->trigger('onHikashopBeforeDisplayView', array(&$this));
		}

		if(!empty($this->toolbar)) {
			$toolbarHelper = hikashop_get('helper.toolbar');
			$toolbarHelper->process($this->toolbar);
		}

		parent::display($tpl); <--***---Here the view is correctly rendered

		if($this->triggerView) {<--****---Even if this is set to false by the debugger the output is still wrong  
			$dispatcher->trigger('onHikashopAfterDisplayView', array( &$this));
		}
	}

I'm going mad with this one! :S :)
-- url of the page with the problem -- : demo.hikashop.com/index.php?option=com_h...NzgmbGFuZz1lbg%3D%3D
-- HikaShop version -- : 2.3.0
-- Joomla version -- : 3.2.2
-- PHP version -- : 5.3.28
-- Browser(s) name and version -- : Firefox 27.0
-- Error-message(debug-mod must be tuned on) -- : No error messsage on screen or PHP error log

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

  • Posts: 13201
  • Thank you received: 2322
10 years 8 months ago #148112

Hi,

I don't really understand the origin of the problem. When do you need to use this url ?

What is the display returned after clicking on an ajax add to cart button ?

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

  • Posts: 3
  • Thank you received: 0
10 years 8 months ago #148234

The sites offers special content to which one can be subscribed.

I need to embed the add to cart links into the content viewers and update the cart module accordingly

The return is like a half processed component..

<div id="system-message-container">
<div id="system-message">
</div>
</div>

Thanks

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 8 months ago #148311

Hi,

What are your talking about ?
Why you are trying to modify the HikaShop helper ?!

1 - Your content is your "component" template page without any specific content except the Joomla messaging system.
That is totally logical because you don't have the right HikaShop configuration to get the cart in return of your ajax call.

2 - For most I understand (and it is not very much) ; Your problem is not in the helper, not even in the view, it should be in the controller.
You are calling the "updatecart" task which depending your HikaShop configuration will work in ajax or not.
In ajax, you will get the cart content otherwise you can be redirected to the "return_url".

3 - You have to first understand the process of the cart before trying to modify a main core file of HikaShop.
And if you want some help to understand some points, please explain them clearly.

If you want to display the cart content, use the cart view.
If you want to update the cart, use the "updatecart" url but be careful with the arguments you put into.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 3
  • Thank you received: 0
10 years 8 months ago #148347

I think I have been misunderstood, I'm not trying to modify Hikashop helper at all, I'm just trying to adapt my code to work with hikashop like hikashop itself does.
The following query in the demo page of hikashop:

demo.hikashop.com/index.php?option=com_h...NzgmbGFuZz1lbg%3D%3D

manages to send all the information needed for the cart to be updated according to the product that is added.
As well as getting back exactly the markup needed to update the cart module
It does it all through the GET query with no additional POST information.

My problem comes if I create a Hikashop category page in my site with some products and click on the add to cart button, it doesn't update the cart module, the query that hikashop sends similar to the one above doesn't bring back the markup to update the cart module (the 'Use AJAX when possible for add to cart buttons' preference is set in the hikashop configuration)

Thanks,

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 8 months ago #148527

It would have been helpful if you had provided the PHP code that you used to generate your add to cart button, and a link to the page with the issue so that we could analyze the result.
Without these, I can only answer you vaguely and tell you that if you want it to work, you need to properly generate the add to the cart button with the call to the javascript function hikashopQuantityChange and make sure that this function is defined in the header of the page with the necessary javascript in it, like HikaShop does for its add to cart buttons. Since it doesn't work with your code, it means that you're missing something, but hard to say what without more information on what you did...

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

Time to create page: 0.074 seconds
Powered by Kunena Forum