Created
          May 19, 2018 06:54 
        
      - 
      
- 
        Save gitSambhal/aa282a357df4bfd0a65414ca608b27ad to your computer and use it in GitHub Desktop. 
    This is CSP customer-specific-pricing-for-woocommerce. File "customer-specific-pricing-for-woocommerce/includes/class-wdm-apply-usp-product-price.php" to show the minimum price for listing of product. Used on https://bestlcds.com
  
        
  
    
      This file contains hidden or 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 showQuantityBasedPricing($price, $product) | |
| { | |
| global $wp_query; | |
| $product_id = self::getProductId($product); | |
| if ($wp_query->queried_object_id != $product_id) { | |
| $csp_prices = self::getQuantityBasedPricing($product_id); | |
| //print_r($csp_prices); | |
| if(sizeof($csp_prices)){ | |
| // Fix zero price issue | |
| return wc_price(self::getDisplayPrice($product, end($csp_prices))); | |
| } | |
| return $price; | |
| } | |
| if (! is_user_logged_in() || !is_product()) { | |
| return $price; | |
| } | |
| $user_id = get_current_user_id(); | |
| $csp_prices = self::getQuantityBasedPricing($product_id); | |
| if (isset($csp_prices) && $csp_prices) { | |
| if (count($csp_prices) === 1) { | |
| $keys = array_keys($csp_prices); | |
| if ($keys[0] == 1) { | |
| return wc_price(self::getDisplayPrice($product, $csp_prices[$keys[0]])) . $product->get_price_suffix(); | |
| } | |
| } | |
| $table = '<div class = "qty-fieldset"><h1 class="qty-legend"><span>' . __('Quantity Discount', CSP_TD) . '</span></h1><table class = "qty_table">'; | |
| $min = $this->getMinQty($csp_prices); | |
| if ($min && $min != 1) { | |
| $price = self::cspGetRegularPrice($product_id); | |
| $table .= "<tr>"; | |
| $table .= "<td class = 'qty-num'>1 ". __(' and more :', CSP_TD) . "</td><td class = 'qty-price'>". wc_price(self::getDisplayPrice($product, $price)) . $product->get_price_suffix() . "</td>"; | |
| $table .= "</tr>"; | |
| } | |
| foreach ($csp_prices as $qty => $price) { | |
| $table .= "<tr>"; | |
| $table .= "<td class = 'qty-num'>".$qty. __(' and more :', CSP_TD) . "</td><td class = 'qty-price'>". wc_price(self::getDisplayPrice($product, $price)) . $product->get_price_suffix() . "</td>"; | |
| $table .= "</tr>"; | |
| } | |
| $table .= "</table></div>"; | |
| return $table; | |
| } | |
| return $price; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment