Using hikashopModifyQuantity

  • Posts: 9
  • Thank you received: 0
  • Hikashop Essential
9 years 10 months ago #187289

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.3
-- Browser(s) name and version -- : Safari 7.1.2

A couple of years ago I developed a theatre ticketing linked to Hikashop to sell tickets for our society's performances and everything worked well. People could click on the seat they wanted and the ticket would be added to the basket. If they changed their mind, they could click on the seat again and the ticket would be removed from the basket. This was achieved through a javascript module which essentially called hikashopModifyQuantity (see below), passing it either +1 or -1 as required.

I have now upgraded to the latest version of Hikashop and this no longer seems to work. It adds the seat just as before - but clicking on the seat again no longer removes it. It appears that hikashopModifyQuantity no longer accepts negative amounts. Is that right? And, if so, is there another way to achieve what I need to do?

Many thanks!
Jonathan

// function toggles seat image and alters quantity in basket
function toggleSeat(seatID,productID,category)
  {
   var x=document.getElementById(seatID).innerHTML;
   var product; // final product ID (corresponding to adult or concession)
   var y;
   var field = new jmt_field;
   
    if (x.search("seat-category") > 0) {
        y=getRadioCheckedValue("ticket_type_form","ticket_type");
        if (y == "Concession") {
            document.getElementById(seatID).innerHTML="<img src=\"http://myco.org.uk/seat-chosen-concession.gif\" title="+seatID+">";
            product = productID + 2;
        }
        else {
            document.getElementById(seatID).innerHTML="<img src=\"http://myco.org.uk/seat-chosen.gif\" title="+seatID+">";
            product = productID + 1;
        } 
        
	field.value = 1;
    }
    else {
    	if (x.search("concession") > 0) {
    		product = productID + 2;
    	}
    	else {
    		product = productID + 1;
    	}
    	document.getElementById(seatID).innerHTML="<img src=\"http://myco.org.uk/seat-category"+category+".gif\" title="+seatID+">";

		field.value = 0;
    }
    
    if (hikashopCheckChangeForm('item','hikashop_product_form'))
    { 
        return hikashopModifyQuantity(product,field,1,0,'cart');
    } 
    else { 
    	return false;
    }
}

Last edit: 9 years 10 months ago by Jerome. Reason: [code] is nice !

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
9 years 10 months ago #187310

Hi,

The 3th parameter of the javascript function hikashopModifyQuantity is the parameter "add" ; it allow you to say if you want to add some quantity or replace the current cart quantity.
So with "add = 1", you can add "1" item.

But I see that you use

field.value = 0;
which means that you shouldn't use the "add = 1" at this moment.
Because you're trying to add "0" items in the cart.. You don't want to add the quantity, you want to replace it.

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.
Last edit: 9 years 10 months ago by Jerome. Reason: [code] is nice
The following user(s) said Thank You: jmtodd

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

  • Posts: 9
  • Thank you received: 0
  • Hikashop Essential
9 years 10 months ago #187456

Brilliant! You're a star! Now works fine.

Many thanks!
Jonathan

PS. Are these things documented anywhere?

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
9 years 10 months ago #187461

Hi,

Our developer documentation does not have the javascript functions ; the fact is that I want to rewrite a big part of them in order to rearrange them and if possible, use javascript objects.
I also planned to add some javascript triggers in HikaShop pages so it will become easier to plug some JS code to catch specific events.

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.

Time to create page: 0.064 seconds
Powered by Kunena Forum