Page 1 of 1

Adding volume discount to search-view

Posted: Tue Jul 07, 2020 6:04 pm
by JD2
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?

Re: Adding volume discount to search-view

Posted: Wed Jul 08, 2020 6:24 pm
by paulfeakins
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.

Re: Adding volume discount to search-view

Posted: Wed Jul 08, 2020 7:33 pm
by letxobnav
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.

Re: Adding volume discount to search-view

Posted: Fri Jul 17, 2020 2:50 pm
by i.am.retailer
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) {

Re: Adding volume discount to search-view

Posted: Mon Jul 20, 2020 3:06 pm
by JD2
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?

Re: Adding volume discount to search-view

Posted: Mon Jul 20, 2020 4:08 pm
by letxobnav

Code: Select all

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

Re: Adding volume discount to search-view

Posted: Mon Jul 20, 2020 5:02 pm
by sw!tch
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

Re: Adding volume discount to search-view

Posted: Tue Jul 21, 2020 10:15 am
by i.am.retailer
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) {