Skip to content

Instantly share code, notes, and snippets.

@Balakrishnan-flycart
Balakrishnan-flycart / Woo Discount Rules v2: Display only least price with prefix in product page strikeout for variable products
Created September 8, 2020 10:21
Woo Discount Rules v2: Display only least price with prefix in product page strikeout for variable products
add_filter('advanced_woo_discount_rules_format_sale_price_range', function($html, $min_price, $max_price){
$html = wc_price($min_price);
return "From ".$html;
}, 10, 3);
@Balakrishnan-flycart
Balakrishnan-flycart / Woo Discount Rules v2 - Switch back option to v1
Last active September 10, 2020 07:41
Woo Discount Rules v2 - Switch back option to v1
add_filter('advanced_woo_discount_rules_has_switch_back_option', '__return_true');
@Balakrishnan-flycart
Balakrishnan-flycart / Woo Discount Rules v2: Change the discounted price of product
Created September 11, 2020 13:59
Woo Discount Rules v2: Change the discounted price of product
/**
* @param $discount_prices array
* @param $product object
* @param $quantity int
* @param $cart_item array
* @return array
* */
add_filter('advanced_woo_discount_rules_discount_prices_of_product', function ($discount_prices, $product, $quantity, $cart_item){
//FOR CHANGING DISCOUNTED_PRICE you can change it in $discount_prices['discounted_price']
@Balakrishnan-flycart
Balakrishnan-flycart / Woo Discount Rules v2 - compatibility Learn dash LMS
Created September 29, 2020 12:43
Woo Discount Rules v2 - compatibility Learn dash LMS
add_filter( 'woocommerce_cart_item_subtotal' ,function($sub_total, $cart_item, $cart_item_key){
if(isset($cart_item['data']->awdr_discount_price) && !empty($cart_item['data']->awdr_discount_price)){
if (isset($cart_item['line_total']) && function_exists('wc_price')) {
return wc_price($cart_item['line_total'], array());
}
}
return $sub_total;
}, 1000, 3 );
@Balakrishnan-flycart
Balakrishnan-flycart / Woo Discount Rules v2 - Category and Attribute Filter And Combination
Created October 1, 2020 06:24
Woo Discount Rules v2 - Category and Attribute Filter And Combination
add_filter('advanced_woo_discount_rules_filter_passed', function ($filter_passed, $rule, $product, $sale_badge) {
//'array(1,2)' - give rule id as you needed
if (in_array($rule->getId(), array(407)) && class_exists('\Wdr\App\Helpers\Woocommerce')) {
$rule_filter = $rule->getFilter();
$categories = \Wdr\App\Helpers\Woocommerce::getProductCategories($product);
$category_ids = array();
if ($rule_filter) {
foreach ($rule_filter as $filter) {
$type = isset($filter->type) ? $filter->type : '';
if ($filter->method == 'in_list') {
@Balakrishnan-flycart
Balakrishnan-flycart / Woo Discount Rules v2: If not show strikeout in Minicart
Created October 6, 2020 10:21
Woo Discount Rules v2: If not show strikeout in Minicart
add_action('woocommerce_before_mini_cart_contents', function (){
if (!WC()->cart->is_empty()){
WC()->cart->calculate_totals();
}
});
@Balakrishnan-flycart
Balakrishnan-flycart / Woo Discount Rules v2 - Compatible with yith woocommerce point & rewards
Last active October 8, 2020 05:41
Woo Discount Rules v2 - Compatible with yith woocommerce point & rewards
add_filter('advanced_woo_discount_rules_exclude_hooks_from_removing', function($allowed_hooks){
if(isset($allowed_hooks['woocommerce_checkout_order_processed'])){
unset($allowed_hooks['woocommerce_checkout_order_processed']);
}
return $allowed_hooks;
});
@Balakrishnan-flycart
Balakrishnan-flycart / Woo Discount Rules v2 - Hide Zero Coupon Value
Created October 8, 2020 11:53
Woo Discount Rules v2 - Hide Zero Coupon Value
add_filter('advanced_woo_discount_rules_hide_zero_value_coupon_html', function($coupon_html, $original_coupon_html, $coupon){
if (class_exists('\Wdr\App\Helpers\Woocommerce')) {
$zero_price_html = '-' . \Wdr\App\Helpers\Woocommerce::formatPrice(0);
$coupon_html = str_replace($zero_price_html, "", $coupon_html);
}
return $coupon_html;
}, 10, 3);
@Balakrishnan-flycart
Balakrishnan-flycart / Woo Discount Rules v2 - Dynamic price update target selector for simple product
Created October 9, 2020 06:36
Woo Discount Rules v2 - Dynamic price update target selector for simple product
add_filter('advanced_woo_discount_rules_custom_target_for_simple_product_on_qty_update', function(){
return "div.product-content.right div.price";
});
@Balakrishnan-flycart
Balakrishnan-flycart / Woo Discount Rules v2 - Combatible with Donation For Woocommerce by wpexpertsio
Created October 9, 2020 07:28
Woo Discount Rules v2 - Combatible with Donation For Woocommerce by wpexpertsio
add_filter('advanced_woo_discount_rules_exclude_hooks_from_removing', function($allowed_hooks){
if(isset($allowed_hooks['woocommerce_before_calculate_totals'])){
unset($allowed_hooks['woocommerce_before_calculate_totals']);
}
return $allowed_hooks;
});