Skip to content
Advertisement

Display a custom message if there are more than 25 products in shopping cart (OpenCart)

I have an OpenCart online market for CD’s. I want when you add some products to the cart and go to the shopping cart page if you are buying more than (>=) 25 products(CD’s) to display message “Please contact us for Delivery Price of more than 25 CD’s.”.

Is there some plugin that can use for it or some other way?

I appreciate all of your advices. Thanks in advance!

Advertisement

Answer

It is not that hard, create a function as:

  public function countProducts() {
    return array_sum($this->session->data['cart']);
  } 

And to your cart template add the following code (where you want to show warning):

<?php 
    if($this->cart->countProducts()>25){ 
        //ofc add your html tags for nice error, this will come ugly :) 
        echo "Please contact us for Delivery Price of more than 25 CD's."
    }
?>

Similar problem can be found here

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement