Last active
March 29, 2022 12:13
-
-
Save codeeshop-oc/6226016c635c34a2357e69c0fb7d744d to your computer and use it in GitHub Desktop.
Opencart - How much amount customer saved in cart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function savedAmountInCart() { | |
$this->load->model('catalog/product'); | |
$saved_amt = 0; | |
foreach ($this->cart->getProducts() as $product) { | |
$product_info = $this->model_catalog_product->getProduct($product['product_id']); | |
$actual_price = 0; | |
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { | |
$actual_price = $product_info['price']; | |
} | |
if ((float) $product_info['special']) { | |
$p = $product_info['special']; | |
$diff = $product['quantity'] * ($actual_price - $p); | |
if ($diff > 0) { | |
$saved_amt += $diff; | |
} | |
} | |
} | |
return $saved_amt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment