Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <modification>
- <id>Starting At Option Price</id>
- <version>1.5.x</version>
- <vqmver>2.1.5</vqmver>
- <author>qphoria</author>
- <file name="catalog/model/catalog/product.php">
- <operation>
- <search position="after"><![CDATA[
- if ($query->num_rows) {
- ]]>
- </search>
- <add><![CDATA[
- $query->row['price'] = ($query->row['discount'] ? $query->row['discount'] : $query->row['price']);
- ]]></add>
- </operation>
- <operation>
- <search position="after"><![CDATA[
- $query->row['price'] = ($query->row['discount'] ? $query->row['discount'] : $query->row['price']);
- ]]></search>
- <add><![CDATA[
- // Show first (lowest) option price as "Starting at" price
- // But for product page, to avoid issues with option price update, use a different method
- if ($query->row['price'] == 0) {
- $options = $this->getProductOptions($product_id);
- $option_prices = array();
- if ($options) {
- foreach ($options as $option) {
- if (!$option['option_value']) { continue; }
- foreach ($option['option_value'] as $option_value) {
- if (!(float)$option_value['price']) { continue; }
- if ($option_value['price_prefix'] == '-') {
- $option_prices[] = -$option_value['price'];
- } else {
- $option_prices[] = $option_value['price'];
- }
- }
- }
- }
- if ($option_prices) {
- sort($option_prices);
- //if (!isset($this->request->get['product_id']) && !isset($this->request->post['product_id'])) {
- //if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH']!='XMLHttpRequest' && !isset($this->request->get['product_id']) && !isset($this->request->post['product_id'])) {
- //if (isset($this->request->get['route']) && $this->request->get['route'] != 'product/product') {
- if ((!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH']!='XMLHttpRequest') && isset($this->request->get['route']) && $this->request->get['route'] != 'product/product') {
- $query->row['price'] = reset($option_prices);
- } else {
- $this->session->data['start_at_price'] = $this->tax->calculate($option_prices[0], $query->row['tax_class_id']);
- $this->session->data['start_at_price_ex_tax'] = $option_prices[0];
- }
- }
- }
- ]]></add>
- </operation>
- </file>
- <file name="system/library/currency.php">
- <operation>
- <search position="after"><![CDATA[
- public function format($number,
- ]]></search>
- <add><![CDATA[
- $trace = debug_backtrace();
- if (isset($trace[1]['class']) && $trace[1]['class'] == 'ControllerProductProduct') {
- if ($number == 0 && !empty($this->session->data['start_at_price'])) {
- $number = $this->session->data['start_at_price'];
- $starting = true;
- unset($this->session->data['start_at_price']);
- }
- if ($number == 0 && !empty($this->session->data['start_at_price_ex_tax'])) {
- $number = $this->session->data['start_at_price_ex_tax'];
- $starting = true;
- unset($this->session->data['start_at_price_ex_tax']);
- }
- }
- ]]></add>
- </operation>
- <operation>
- <search position="before"><![CDATA[
- return $string;
- ]]></search>
- <add><![CDATA[
- if (isset($starting) && $starting) {
- $starting = false;
- $string = "Starting at $string";
- }
- ]]></add>
- </operation>
- </file>
- </modification>
Advertisement
Add Comment
Please, Sign In to add comment