Post by Mirbrou » Tue Oct 16, 2018 6:25 am

In my store, I sell fabrics and products related to sewing. The fabrics are displayed in decimal as 1.5 meters and the various products in units. I use an "if" function with categories.
This code works well when using categories to find a product. But when using the search function, the product loses its category. And we get, for example, for "button" = 0.25 m! It is a problem!

You can go to the situation: cotonflanelle.com
For example, search: READY SEWING KIT

Code: Select all

<div class="cart">
	<div class="add-to-cart clearfix">
			          <p><label class="control-label" for="input-quantity"><?php echo $entry_qty; ?></label>
			              <div class="quantity" style="padding: 7px 10px 5px 0px;">
                    <?php if (($category_id=="51")or($category_id=="55")or($category_id=="109")or($category_id=="265")or($category_id=="282")or($category_id=="283")or($category_id=="292")or($category_id=="294")or($category_id=="306")or($category_id=="186")or($category_id=="187")or($category_id=="188")or($category_id=="189")or($category_id=="190")) { ?>
                                           <input type="text" name="quantity" id="quantity_wanted" size="4" value="1" type="number" step="1" />

                                        <script>
                                          $(document).ready(function() {
                                          $("#quantity").change(function() {
                                          $(this).val(Math.ceil($(this).val()));
                                          });
                                          });
                                        </script>
                  <?php } else { ?>
                   <select id="quantity" name="quantity">
                      <option value="0.25">0.25 m</option>
                      <option value="0.50">0.50 m</option>
                      <option value="0.75">0.75 m</option>
                      <option value="1.00">1 m</option>
                      <option value="1.25">1.25 m</option>
                      <option value="1.50">1.50 m</option>
                      <option value="1.75">1.75 m</option>
                      <option value="2.00">2 m</option>
                      <option value="2.25">2.25 m</option>
                      <option value="2.50">2.50 m</option>
                      <option value="2.75">2.75 m</option>
                      <option value="3.00">3 m</option>
                      <option value="3.25">3.25 m</option>
                      <option value="3.50">3.50 m</option>
                      <option value="3.75">3.75 m</option>
                      <option value="4.00">4 m</option>
                      <option value="4.25">4.25 m</option>
                      <option value="4.50">4.50 m</option>
                      <option value="4.75">4.75 m</option>
                      <option value="5.00">5 m</option></select>
                  <?php } ?>
            </div>
			          </p>
		    
			          <input type="hidden" name="product_id" size="1" value="<?php echo $product_id; ?>" />
			          &nbsp;
						<?php if($theme_options->get( 'display_add_to_cart' ) != '0' ) { ?>
							<div class="cart-holder">
								<input type="button" value="<?php if($theme_options->get( 'add_to_cart_text', $config->get( 'config_language_id' ) ) != '') { echo $theme_options->get( 'add_to_cart_text', $config->get( 'config_language_id' ) ); } else { echo 'Add to cart'; } ?>" id="button-cart" rel="<?php echo $product_id; ?>" class="button" />
								<a href="<?php echo "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; ?>" class="button" id="button-more-details"><?php if($theme_options->get( 'more_details_text', $config->get( 'config_language_id' ) ) != '') { echo html_entity_decode($theme_options->get( 'more_details_text', $config->get( 'config_language_id' ) )); } else { echo 'More details'; } ?></a>
							</div>
						<?php } ?>
</div>
How to make sure the product keeps its category?

I had thought of using the tag, but this way seems more complicated to me. Would there be a module that could do what I want?

Thank you for your help !
Last edited by Mirbrou on Tue Oct 16, 2018 9:43 pm, edited 1 time in total.

https://cotonflanelle.com in OC2.3.0.2
Kingstorepro - ThemeGlobal
Advanced SEO - Webkul
Product Preorder Pro - Webkul
Webkul Quickbook Connector - Webkul
Customers Also Viewed / Purchased
opencart-2-x-export-import-multilingual-3-12 - J. Neuhoff


Newbie

Posts

Joined
Tue Jun 27, 2017 6:25 am

Post by straightlight » Tue Oct 16, 2018 6:30 am

Posted in wrong forum section.

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Mirbrou » Tue Oct 16, 2018 7:03 am

How to change or delete ?

https://cotonflanelle.com in OC2.3.0.2
Kingstorepro - ThemeGlobal
Advanced SEO - Webkul
Product Preorder Pro - Webkul
Webkul Quickbook Connector - Webkul
Customers Also Viewed / Purchased
opencart-2-x-export-import-multilingual-3-12 - J. Neuhoff


Newbie

Posts

Joined
Tue Jun 27, 2017 6:25 am

Post by paulfeakins » Tue Oct 16, 2018 5:42 pm

Mirbrou wrote:
Tue Oct 16, 2018 7:03 am
How to change or delete ?
Moved to OC2 support.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by Mirbrou » Tue Oct 16, 2018 9:57 pm

Thank you, the message has been moved!

So, do you have an idea for my problem?
:)

https://cotonflanelle.com in OC2.3.0.2
Kingstorepro - ThemeGlobal
Advanced SEO - Webkul
Product Preorder Pro - Webkul
Webkul Quickbook Connector - Webkul
Customers Also Viewed / Purchased
opencart-2-x-export-import-multilingual-3-12 - J. Neuhoff


Newbie

Posts

Joined
Tue Jun 27, 2017 6:25 am
Who is online

Users browsing this forum: No registered users and 20 guests