This file contains 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
add_filter('advanced_woo_discount_rules_custom_target_for_simple_product_on_qty_update', function ($target){ | |
$target = 'div.btn-price'; | |
return $target; | |
}, 10); |
This file contains 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
add_action('wp', function (){ | |
global $post; | |
if (is_page() && is_object($post) && isset($post->post_content)) { | |
if (has_shortcode($post->post_content, 'awdr_sale_items_list')) { | |
remove_filter( 'woocommerce_after_shop_loop', 'roleWcAdcellTrackingCategoryRetargeting', 10 ); | |
} | |
} | |
}); |
This file contains 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
<?php | |
global $product; // or use wc_get_product() function for get product object | |
$sale_price = $product->get_price(); | |
$discount = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $sale_price, $product, 1, 0, 'discounted_price', true, false); | |
if($discount !== false) { | |
$sale_price = $discount; | |
} | |
$product_price_excluding_tax = wc_get_price_excluding_tax( $product ,array('price' => $sale_price)); // get product price with excluding tax | |
$product_price_including_tax = wc_get_price_including_tax( $product ,array('price' => $sale_price)); // get product price with including tax |
This file contains 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
add_filter('advanced_woo_discount_rules_discount_prices_of_product', function ($discount_prices, $product, $quantity, $cart_item){ | |
if ($product && method_exists($product,'get_id') && function_exists('get_field')){ | |
$product_id = $product->get_id(); | |
$max_discount_price = get_field( "max_discount_amount", $product_id); | |
if (!empty($max_discount_price) && isset($discount_prices['discounted_price']) && class_exists('\Wdr\App\Controllers\ManageDiscount')) { | |
$calculator = \Wdr\App\Controllers\ManageDiscount::$calculator; | |
$discount_price = $discount_prices['initial_price'] - $discount_prices['discounted_price']; | |
if ($discount_price > $max_discount_price) { | |
$discount_prices['discounted_price'] = $discount_prices['initial_price'] - $max_discount_price; |
This file contains 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
if (!function_exists('advanced_woo_discount_rules_get_add_on_price_with_discount')) { | |
function advanced_woo_discount_rules_get_add_on_price_with_discount($product_price, $product, $quantity, $cart_item, $calculate_discount_from) { | |
if (!empty($cart_item) && isset($cart_item['product_extras']) && !empty($cart_item['product_extras']) && isset($cart_item['product_extras']['price_with_extras']) && !empty($cart_item['product_extras']['price_with_extras'])) { | |
$product_price = $cart_item['product_extras']['price_with_extras']; | |
} | |
return $product_price; | |
} | |
add_filter('advanced_woo_discount_rules_product_original_price_on_before_calculate_discount', 'advanced_woo_discount_rules_get_add_on_price_with_discount', 100, 5); | |
add_filter('advanced_woo_discount_rules_product_price_on_before_calculate_discount', 'advanced_woo_discount_rules_get_add_on_price_with_discount', 100, 5); | |
} |
This file contains 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
add_action('graphql_register_types', function () { | |
register_graphql_field('Product', 'discountTableAndBar', [ | |
'type' => 'String', | |
'description' => 'The HTML for the discount table and bar for this product.', | |
'resolve' => function($product) { | |
ob_start(); | |
do_action('advanced_woo_discount_rules_load_discount_bar', wc_get_product($product->get_id())); |
This file contains 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
if (!function_exists('advanced_woo_discount_rules_is_active_rule')) { | |
function advanced_woo_discount_rules_is_active_rule($rule_id) | |
{ | |
if (class_exists('Wdr\App\Controllers\ManageDiscount') && !empty(\Wdr\App\Controllers\ManageDiscount::$available_rules)) { | |
$rule_ids = array_keys(\Wdr\App\Controllers\ManageDiscount::$available_rules); | |
return in_array($rule_id, $rule_ids); | |
} else { | |
return false; | |
} | |
} |
This file contains 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
// Disable to the each rules | |
add_filter('advanced_woo_discount_rules_do_process_discounts_of_each_rule', '__return_false'); |
This file contains 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
if(!function_exists('reCalculateTotalOnAjaxCashpay')){ | |
function reCalculateTotalOnAjaxCashpay() | |
{ | |
if (function_exists('WC')) { | |
if(isset(WC()->cart) && WC()->cart != null){ | |
if (is_object(WC()->cart) && method_exists(WC()->cart, 'calculate_totals')) { | |
WC()->cart->calculate_totals(); | |
} | |
} | |
} |
This file contains 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
add_action( 'wp', function () { | |
if ( ! current_user_can( 'manage_options' ) ) { | |
show_admin_bar( false ); | |
} | |
} ); |