Skip to content

Instantly share code, notes, and snippets.

@Kowsaliya
Kowsaliya / Remove Woocommerce message when discount rules coupon is applied
Created August 13, 2020 12:36
Remove Woocommerce message when discount rules coupon is applied
add_filter('woocommerce_coupon_message', function ($msg, $msg_code, $coupon){
if(!empty($coupon)){
if(method_exists($coupon, 'get_code')){
$applicable_coupons = array('blackfridaysale'); //COUPON
$coupon_code = $coupon->get_code(); //Applied COUPON
//DO THE PROCESS FOR CHECKING THE CONDITION MATCHES OR NOT
if(in_array($coupon_code, $applicable_coupons)){
$msg = ''; //YOU CAN CUSTOMIZE THE MESSAGE HERE
}
}
@Kowsaliya
Kowsaliya / Discount rules v2: Round discount value
Last active July 30, 2020 07:56
Discount rules v2: Round discount value
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']
$discount_prices['discounted_price'] = wc_round_discount($discount_prices['discounted_price'], 2);
return $discount_prices;
}, 10, 4);
@Kowsaliya
Kowsaliya / gist:9becebe0a56b88789081d0e51ec7f197
Last active July 8, 2020 07:26
Message to show when Disable coupons options is chosen
add_filter('advanced_woo_discount_rules_notice_on_remove_coupon_while_having_a_discount', function ($msg, $coupon_code){
$msg = 'The product(s) in your shopping basket are already discounted up to 15% or more than the value of your Coupon code "'.$coupon_code.'". The Coupon code discount is therefore already applied.'; //YOU CAN CUSTOMIZE THE MESSAGE HERE
return $msg;
}, 10, 2);
@Kowsaliya
Kowsaliya / gist:8b343fc4568a1e6809775401fd6d5612
Created June 29, 2020 08:20
Remove coupon message when coupon is applied
add_filter('woocommerce_coupon_message', function ($msg, $msg_code, $coupon){
if(!empty($coupon)){
if(method_exists($coupon, 'get_code')){
$coupon_code = $coupon->get_code(); //Applied COUPON
//DO THE PROCESS FOR CHECKING THE CONDITION MATCHES OR NOT
if($coupon_code == 'FREENEONGOBY' || $coupon_code == 'freeneongoby'){
$msg = ''; //YOU CAN CUSTOMIZE THE MESSAGE HERE
}
}
}
@Kowsaliya
Kowsaliya / gist:e62c2f7601cb12261233a9aa34e8df9d
Created June 1, 2020 13:02
Email Customizer Plus : Show Product item price in order table
<div class="email-product-list" style="padding: 15px 25px;">
<?php
/**
* Order details table shown in emails.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
* will need to copy the new files to your theme to maintain compatibility. We try to do this.
* as little as possible, but it does happen. When this occurs the version of the template file will.
* be bumped and the readme will list any important changes.
@Kowsaliya
Kowsaliya / Email Customizer Plus : Get Product URL link
Last active May 22, 2020 12:12
Email Customizer Plus : Get Product URL link
function woo_discount_rules_discount_amount_before_apply_method($discount_amount){
$discount_amount = wc_round_discount($discount_amount, 1);
return $discount_amount;
}
add_filter('woo_discount_rules_discount_amount_before_apply', 'woo_discount_rules_discount_amount_before_apply_method', 10);
@Kowsaliya
Kowsaliya / Woo Discount Rules: For applying discount on base price and add on price main while using Woocommerce product addon
Created February 21, 2020 08:25
Woo Discount Rules: For applying discount on base price and add on price main while using Woocommerce product addon
if(!function_exists('woo_discount_rules_has_price_override_method')){
function woo_discount_rules_has_price_override_method($has_price_override, $product, $on_apply_discount){
return true;
}
}
add_filter('woo_discount_rules_has_price_override', 'woo_discount_rules_has_price_override_method', 10, 3);
function woo_discount_rules_price_rule_final_amount_applied_method($discountedPrice, $price, $discount, $additionalDetails, $product, $product_page){
if($discountedPrice < 0) $discountedPrice = 0;
$total_price = $product->get_price();
@Kowsaliya
Kowsaliya / Woo Discount Rules: For applying discount on base price and add on price main while using Woocommerce product addon
Created February 21, 2020 08:25
Woo Discount Rules: For applying discount on base price and add on price main while using Woocommerce product addon
if(!function_exists('woo_discount_rules_has_price_override_method')){
function woo_discount_rules_has_price_override_method($has_price_override, $product, $on_apply_discount){
return true;
}
}
add_filter('woo_discount_rules_has_price_override', 'woo_discount_rules_has_price_override_method', 10, 3);
function woo_discount_rules_price_rule_final_amount_applied_method($discountedPrice, $price, $discount, $additionalDetails, $product, $product_page){
if($discountedPrice < 0) $discountedPrice = 0;
$total_price = $product->get_price();
@Kowsaliya
Kowsaliya / Some plugin overrides
Created February 11, 2020 06:11
DiscountRules
if(!function_exists('woo_discount_rules_has_price_override_method')){
function woo_discount_rules_has_price_override_method($hasPriceOverride, $product){
return true;
}
}
add_filter('woo_discount_rules_has_price_override', 'woo_discount_rules_has_price_override_method', 10, 2);