Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AshlinRejo/9c15af04033010c9dc25137fa12c514e to your computer and use it in GitHub Desktop.
Save AshlinRejo/9c15af04033010c9dc25137fa12c514e to your computer and use it in GitHub Desktop.
Add the below code in template function.pho to support WooCommerce Wholesale Prices Premium - Rymera Web Co with Woo Discount rules
if(!function_exists('woo_discount_rules_remove_event_woocommerce_before_calculate_totals_for_wholesale_prices')){
/**
* Compatible for Wholesale price
* */
function woo_discount_rules_remove_event_woocommerce_before_calculate_totals_for_wholesale_prices($remove_event){
return true;
}
}
add_filter('woo_discount_rules_remove_event_woocommerce_before_calculate_totals', 'woo_discount_rules_remove_event_woocommerce_before_calculate_totals_for_wholesale_prices');
if(!function_exists('wholesalePluginStrikeOutHTML')){
/**
* Compatible for Wholesale price
* */
function wooDiscountCompatibleWithWholesalePluginStrikeOutHTML($wholesale_price_html , $price , $product , $user_wholesale_role , $wholesale_price_title_text , $raw_wholesale_price , $source){
global $flycart_woo_discount_rules;
if(isset($flycart_woo_discount_rules->pricingRules)){
if(empty($raw_wholesale_price)){
$product->woo_discount_rules_do_not_run_strikeout = 1;
} else {
$product->set_price($raw_wholesale_price);
$wholesale_price_html = $flycart_woo_discount_rules->pricingRules->replaceVisiblePricesOptimized($wholesale_price_html, $product);
$product->woo_discount_rules_do_not_run_strikeout = 1;
}
}
return $wholesale_price_html;
}
}
add_filter('wwp_filter_wholesale_price_html', 'wooDiscountCompatibleWithWholesalePluginStrikeOutHTML', 100, 7);
if(!function_exists('checkHasWholesalePriceForAnProduct')){
/**
* check has whole sale price for the Plugin WooCommerce Wholesale Prices Premium - Rymera Web Co
*
* @param boolean $hasWholesalePrice
* @param object $product
* @return boolean
* */
function checkHasWholesalePriceForAnProduct($hasWholesalePrice, $product){
if(isset($product->wwp_data)){
if(isset($product->wwp_data['wholesale_priced']) && $product->wwp_data['wholesale_priced'] == 'yes'){
$hasWholesalePrice = 1;
}
}
return $hasWholesalePrice;
}
}
add_filter('woo_discount_rules_has_price_override', 'checkHasWholesalePriceForAnProduct', 10, 2);
if(!function_exists('wooDiscountCompatibleWithWholesaleOnSaleTagEnabled')){
/**
* Compatible for Wholesale price
*
* @param boolean $do_strikeout_on_sale
* @param object $product
* @return boolean
* */
function wooDiscountCompatibleWithWholesaleOnSaleTagEnabled($do_strikeout_on_sale, $product){
return false;
}
}
add_filter('woo_discount_rules_do_sale_tag_through_strikeout_price', 'wooDiscountCompatibleWithWholesaleOnSaleTagEnabled', 10, 2);
if(!function_exists('wooDiscountCompatibleWithWholesaleBeforePriceStrkeout')){
/**
* Compatible for Wholesale price
*
* @param string $price_html
* @param object $product
* @return boolean
* */
function wooDiscountCompatibleWithWholesaleBeforePriceStrkeout($price_html, $product){
$price_html = str_replace('<del class="original-computed-price">', '', $price_html);
$price_html = str_replace('</del>', '', $price_html);
return $price_html;
}
}
add_filter('woo_discount_rules_price_strikeout_before_discount_price', 'wooDiscountCompatibleWithWholesaleBeforePriceStrkeout', 10, 2);
if(!function_exists('wooDiscountCompatibleWithWholesaleStrkeoutForVariation')){
/**
* Compatible for Wholesale price
*
* @param boolean $strike_out_with_ajax
* @param object $product
* @return boolean
* */
function wooDiscountCompatibleWithWholesaleStrkeoutForVariation($strike_out_with_ajax, $product){
return false;
}
}
add_filter('woo_discount_rules_run_variation_strike_out_with_ajax', 'wooDiscountCompatibleWithWholesaleStrkeoutForVariation', 10, 2);
if(!function_exists('woo_discount_rules_run_variation_strikeout_through_ajax_method')){
function woo_discount_rules_run_variation_strikeout_through_ajax_method($do_ajax){
return false;
}
}
add_filter('woo_discount_rules_run_variation_strikeout_through_ajax', 'woo_discount_rules_run_variation_strikeout_through_ajax_method');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment