Guest User

Untitled

a guest
Sep 11th, 2012
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 3.34 KB | None | 0 0
  1. <modification>
  2.     <id>Starting At Option Price</id>
  3.     <version>1.5.x</version>
  4.     <vqmver>2.1.5</vqmver>
  5.     <author>qphoria</author>
  6.     <file name="catalog/model/catalog/product.php">
  7.         <operation>
  8.             <search position="after"><![CDATA[
  9.             if ($query->num_rows) {
  10.             ]]>
  11.             </search>
  12.             <add><![CDATA[
  13.             $query->row['price'] = ($query->row['discount'] ? $query->row['discount'] : $query->row['price']);         
  14.             ]]></add>
  15.         </operation>
  16.    
  17.         <operation>
  18.             <search position="after"><![CDATA[
  19.             $query->row['price'] = ($query->row['discount'] ? $query->row['discount'] : $query->row['price']);
  20.             ]]></search>
  21.             <add><![CDATA[
  22.            
  23.             // Show first (lowest) option price as "Starting at" price
  24.             // But for product page, to avoid issues with option price update, use a different method
  25.             if ($query->row['price'] == 0) {
  26.                 $options = $this->getProductOptions($product_id);
  27.                
  28.                 $option_prices = array();
  29.                 if ($options) {
  30.                     foreach ($options as $option) {
  31.                         if (!$option['option_value']) { continue; }
  32.                         foreach ($option['option_value'] as $option_value) {
  33.                             if (!(float)$option_value['price']) { continue; }
  34.                             if ($option_value['price_prefix'] == '-') {
  35.                                 $option_prices[] = -$option_value['price'];
  36.                             } else {
  37.                                 $option_prices[] = $option_value['price'];
  38.                             }
  39.                         }
  40.                     }
  41.                 }
  42.                 if ($option_prices) {
  43.                     sort($option_prices);
  44.                     //if (!isset($this->request->get['product_id']) && !isset($this->request->post['product_id'])) {
  45.                     //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'])) {
  46.                     //if (isset($this->request->get['route']) && $this->request->get['route'] != 'product/product') {
  47.                     if ((!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH']!='XMLHttpRequest') && isset($this->request->get['route']) && $this->request->get['route'] != 'product/product') {
  48.                         $query->row['price'] = reset($option_prices);
  49.                     } else {
  50.                         $this->session->data['start_at_price'] = $this->tax->calculate($option_prices[0], $query->row['tax_class_id']);
  51.                         $this->session->data['start_at_price_ex_tax'] = $option_prices[0];
  52.                     }
  53.                 }              
  54.             }
  55.             ]]></add>
  56.         </operation>
  57.     </file>
  58.    
  59.     <file name="system/library/currency.php">
  60.         <operation>
  61.             <search position="after"><![CDATA[
  62.             public function format($number,
  63.             ]]></search>
  64.             <add><![CDATA[
  65.             $trace = debug_backtrace();
  66.             if (isset($trace[1]['class']) && $trace[1]['class'] == 'ControllerProductProduct') {
  67.                 if ($number == 0 && !empty($this->session->data['start_at_price'])) {
  68.                     $number = $this->session->data['start_at_price'];
  69.                     $starting = true;
  70.                     unset($this->session->data['start_at_price']);
  71.                 }
  72.                 if ($number == 0 && !empty($this->session->data['start_at_price_ex_tax'])) {
  73.                     $number = $this->session->data['start_at_price_ex_tax'];
  74.                     $starting = true;
  75.                     unset($this->session->data['start_at_price_ex_tax']);
  76.                 }
  77.             }
  78.             ]]></add>
  79.         </operation>
  80.         <operation>
  81.             <search position="before"><![CDATA[
  82.             return $string;
  83.             ]]></search>
  84.             <add><![CDATA[
  85.             if (isset($starting) && $starting) {
  86.                 $starting = false;
  87.                 $string = "Starting at $string";
  88.             }
  89.             ]]></add>
  90.         </operation>
  91.        
  92.     </file>
  93.  
  94. </modification>
Advertisement
Add Comment
Please, Sign In to add comment