Quantity drop-down being changed by Javascript?
- sloanthrasher
-
Topic Author
- Offline
Less
More
13 years 4 months ago #105072
by sloanthrasher
Sloan Thrasher
Quantity drop-down being changed by Javascript? was created by sloanthrasher
Hi,
I have a drop-down that I've added in a product listing for the quantity to use with Add To Cart. When the page is displayed, the <select>...</select> statement changes to css display:none; and a pseudo drop-down is added. It looks nice, but doesn't function, or at least the quantity selected is ignored when the user clicks Add To Cart.
Here's the modified code as it appears in FireBug:
Here's the select before it's modified:
Is there a way to prevent the pseudo combo from being created? If not, how can I get the Add To Cart to recognize the value selected?
Thanks!
I have a drop-down that I've added in a product listing for the quantity to use with Add To Cart. When the page is displayed, the <select>...</select> statement changes to css display:none; and a pseudo drop-down is added. It looks nice, but doesn't function, or at least the quantity selected is ignored when the user clicks Add To Cart.
Here's the modified code as it appears in FireBug:
Code:
<div id="hikashop_product_quantity_field_4_chzn" class="chzn-container chzn-container-single chzn-container-single-nosearch" style="width: 158px;display:none;">
<a class="chzn-single" href="javascript:void(0)">
<span>(1) Sample $1.00 ea.</span>
<div>
<b></b>
</div>
</a>
<div class="chzn-drop" style="display: none; width: 156px; top: 25px;">
<div class="chzn-search">
<input type="text" autocomplete="off" style="width: 121px;">
</div>
<ul class="chzn-results">
<li id="hikashop_product_quantity_field_4_chzn_o_0" class="active-result result-selected" style="">(1) Sample $1.00 ea.</li>
<li id="hikashop_product_quantity_field_4_chzn_o_1" class="active-result" style="">(50) $12.50 ($0.25 ea.)</li>
<li id="hikashop_product_quantity_field_4_chzn_o_2" class="active-result" style="">(100) $24.00 ($0.24 ea.)</li>
<li id="hikashop_product_quantity_field_4_chzn_o_3" class="active-result" style="">(990) $217.80 ($0.22 ea.)</li>
</ul>
</div>
</div>
Here's the select before it's modified:
Code:
<select id="hikashop_product_quantity_field_4" name="data[4]" class="hikashop_listing_quantity_field_combo">
<option value='1'>(1) Sample $1.00 ea.</option>
<option value='50'>(50) $12.50 ($0.25 ea.)</option>
<option value='100'>(100) $24.00 ($0.24 ea.)</option>
<option value='990'>(990) $217.80 ($0.22 ea.)</option>
</select>
Is there a way to prevent the pseudo combo from being created? If not, how can I get the Add To Cart to recognize the value selected?
Thanks!
Sloan Thrasher
Please Log in or Create an account to join the conversation.
13 years 4 months ago #105114
by Jerome
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.
Replied by Jerome on topic Quantity drop-down being changed by Javascript?
Hi,
HikaShop uses the javascript library "Chosen" with Joomla 3.
You can deactivate it in the HikaShop configuration.
www.hikashop.com/en/support/documentatio...html#display_general
Regards,
HikaShop uses the javascript library "Chosen" with Joomla 3.
You can deactivate it in the HikaShop configuration.
www.hikashop.com/en/support/documentatio...html#display_general
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.
The following user(s) said Thank You: sloanthrasher
Please Log in or Create an account to join the conversation.
- sloanthrasher
-
Topic Author
- Offline
13 years 4 months ago #105171
by sloanthrasher
Sloan Thrasher
Replied by sloanthrasher on topic Quantity drop-down being changed by Javascript?
Thanks Jerome.
I Tturned that off, but it still add just one of the item to the cart no matter what the user selects from the drop down. I double checked, and the javascript references the correct field ID of the select.
I must be missing something obvious (slaps forehead)!
I Tturned that off, but it still add just one of the item to the cart no matter what the user selects from the drop down. I double checked, and the javascript references the correct field ID of the select.
I must be missing something obvious (slaps forehead)!
Sloan Thrasher
Please Log in or Create an account to join the conversation.
13 years 4 months ago #105194
by nicolas
Replied by nicolas on topic Quantity drop-down being changed by Javascript?
Maybe you have twice the same id on the page and because of that the system doesn't take the correct input into account.
We would need to look at the HTML of the page to see that but it seems like a plausible reason.
We would need to look at the HTML of the page to see that but it seems like a plausible reason.
Please Log in or Create an account to join the conversation.
- sloanthrasher
-
Topic Author
- Offline
13 years 4 months ago #105535
by sloanthrasher
Sloan Thrasher
Replied by sloanthrasher on topic Quantity drop-down being changed by Javascript?
Hi Nicolas,
You are right about the field ID appearing twice. I found a hidden quantity field when looking at the page source, but I can't find where in the php code this field is created. If you could point out where it is, then I should be able to make the change so that when the select is created, it is not generated. I'm afraid of just willy-nilly making a change since it could affect other places or have unintended consequences.
Thanks again for all of your help!
You are right about the field ID appearing twice. I found a hidden quantity field when looking at the page source, but I can't find where in the php code this field is created. If you could point out where it is, then I should be able to make the change so that when the select is created, it is not generated. I'm afraid of just willy-nilly making a change since it could affect other places or have unintended consequences.
Thanks again for all of your help!
Sloan Thrasher
Please Log in or Create an account to join the conversation.
13 years 4 months ago #105554
by nicolas
Replied by nicolas on topic Quantity drop-down being changed by Javascript?
Hi,
As I don't know how you configured HikaShop and I don't know either the HTML of your pages, it's hard to say for sure, especially since there is no such problem by default in HikaShop, which means that it comes from a modification you made.
There is a high probability that you can fix it by removing the hidden quantity field in the file administrator/components/com_hikashop/helpers/cart.php but it might be something else, and it might actually break something else.
As I don't know how you configured HikaShop and I don't know either the HTML of your pages, it's hard to say for sure, especially since there is no such problem by default in HikaShop, which means that it comes from a modification you made.
There is a high probability that you can fix it by removing the hidden quantity field in the file administrator/components/com_hikashop/helpers/cart.php but it might be something else, and it might actually break something else.
Please Log in or Create an account to join the conversation.
- sloanthrasher
-
Topic Author
- Offline
13 years 4 months ago #105561
by sloanthrasher
Sloan Thrasher
Replied by sloanthrasher on topic Quantity drop-down being changed by Javascript?
My apologies. Of course, you are right. It would be difficult to impossible to know the answer without knowing the change I made! Duh! Sorry about that!
I changed the add_to_cart_listing.php and listing_img_title.php files. In listing_img_title.php I test to see if there are multiple prices, and then set a $_REQUEST value to the item's product ID. In the add_to_cart_listing.php file, and I added code to look-up the quantity price breaks, and create the drop-down. The value set in $_REQUEST is tested in add_to_cart_listing.php to determine whether or not to create the drop-down.
The hidden quantity field is created somewhere between the <form> tag (created in add_to_cart_listing.php) and the Add To Cart button, also created in add_to_cart_listing.php, but I do not see any code there to create the field.
Update:
As I was writing this, I finally figured out where the hidden quantity field was being added. It is in the cart.php in administrator/.../helpers file. I added the same text against the $_REQUEST variable as I use in add_to_cart_listing.php to eliminate the hidden quantity field. It all works now.
I probably would not have found it without the clues you provided, or if I had not had to think through all of the above.
Thanks for the help Nicolas!
I changed the add_to_cart_listing.php and listing_img_title.php files. In listing_img_title.php I test to see if there are multiple prices, and then set a $_REQUEST value to the item's product ID. In the add_to_cart_listing.php file, and I added code to look-up the quantity price breaks, and create the drop-down. The value set in $_REQUEST is tested in add_to_cart_listing.php to determine whether or not to create the drop-down.
The hidden quantity field is created somewhere between the <form> tag (created in add_to_cart_listing.php) and the Add To Cart button, also created in add_to_cart_listing.php, but I do not see any code there to create the field.
Update:
As I was writing this, I finally figured out where the hidden quantity field was being added. It is in the cart.php in administrator/.../helpers file. I added the same text against the $_REQUEST variable as I use in add_to_cart_listing.php to eliminate the hidden quantity field. It all works now.
I probably would not have found it without the clues you provided, or if I had not had to think through all of the above.
Thanks for the help Nicolas!
Sloan Thrasher
Please Log in or Create an account to join the conversation.
Time to create page: 0.203 seconds