Post by JD2 » Tue Jul 07, 2020 6:04 pm

Hi! I'd like to add volume discounts to my search-view. I already added

Code: Select all

 <div class="list-unstyled">
                  {% if discounts %}
                  <li>
                    <hr>
                  </li>
                  {% for discount in discounts %}
                  <li>Vanaf {{ discount.quantity }} <b> {{ discount.price }} </b></li>
                  {% endfor %}
                  {% endif %}
                </div>
to product / search.twig under the pricing. I simply copied this from product / product.twig because it works there. I'm not sure what to add to the controller/product/search.php file.

Could someone help me with this?

JD2
New member

Posts

Joined
Thu Jun 11, 2020 7:42 pm

Post by paulfeakins » Wed Jul 08, 2020 6:24 pm

JD2 wrote:
Tue Jul 07, 2020 6:04 pm
Could someone help me with this?
You could pay a developer such as ourselves or post a job in the Commercial Support Forum.

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


User avatar
Guru Member

Posts

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

Post by letxobnav » Wed Jul 08, 2020 7:33 pm

as product / search.twig displays multiple products, just like product/category.twig, it works totally different from product/product.twig which is designed to just display a single product.

Better not copy and past between those just because it works in one of them.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by i.am.retailer » Fri Jul 17, 2020 2:50 pm

catalog>>controller>>product>>search.php
in the above file inside the product result for loop foreach every product add

Code: Select all

$results = $this->model_catalog_product->getProducts($filter_data);
foreach ($results as $result) {
Last edited by i.am.retailer on Tue Jul 21, 2020 10:19 am, edited 2 times in total.

New member

Posts

Joined
Thu Jun 04, 2020 2:10 pm

Post by JD2 » Mon Jul 20, 2020 3:06 pm

Hi! Thanks for the code, I think this will solve the problem. I added all the code, but I'm not sure I added

Code: Select all

$prod_discount = array();
							foreach ($discounts as $discount) {
									 $prod_discount[] = array(
																 'quantity' => $discount['quantity'],
																	'price'    => $this->currency->format($this->tax->calculate($discount['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'])
																			 );
															 }
in the right place. Could you explain where this should be placed?

JD2
New member

Posts

Joined
Thu Jun 11, 2020 7:42 pm

Post by letxobnav » Mon Jul 20, 2020 4:08 pm

Code: Select all

 foreach ($discounts as $discount) {
and where does $discounts come from then?

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by sw!tch » Mon Jul 20, 2020 5:02 pm

letxobnav wrote:
Mon Jul 20, 2020 4:08 pm

Code: Select all

 foreach ($discounts as $discount) {
and where does $discounts come from then?
Exact reason I told this user not to paste half baked code. viewtopic.php?f=202&t=218816&p=793522#p793525

Backup and [ learn how to recover ] before you make any changes.


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by i.am.retailer » Tue Jul 21, 2020 10:15 am

Hi in the search.php after the product list result there will be foreach loop call inside that you need

Code: Select all

$results = $this->model_catalog_product->getProducts($filter_data);

			foreach ($results as $result) {

New member

Posts

Joined
Thu Jun 04, 2020 2:10 pm
Who is online

Users browsing this forum: No registered users and 14 guests