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 ( class_exists('\Wdr\App\Controllers\ManageDiscount')) { | |
if (is_a($product, 'WC_Product')) { | |
$manage_discount = new \Wdr\App\Controllers\ManageDiscount(); | |
$price_html = "<div class='price'></div>"; | |
$product_qty = 1; | |
$price_html = $manage_discount->getPriceHtml($price_html, $product, $product_qty, true); | |
} | |
} |
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
/** | |
* Hide shipping rates when discount rules free shipping is available. | |
* Updated to support WooCommerce 2.6 Shipping Zones. | |
* | |
* @param array $rates Array of rates found for the package. | |
* @return array | |
*/ | |
function my_hide_shipping_when_free_is_available( $rates ) { | |
$free = array(); | |
foreach ( $rates as $rate_id => $rate ) { |
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 ( class_exists('\Wdr\App\Controllers\ManageDiscount')) { | |
$manage_discount = new \Wdr\App\Controllers\ManageDiscount(); | |
$manage_discount->calculateCartPageDiscounts(); | |
$discount_details = \Wdr\App\Controllers\ManageDiscount::$calculated_cart_item_discount; | |
// $discount_details -> details of discounts array | |
} |
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
$items = $order->get_items(); //order object | |
if (!empty($items) && class_exists('\Wdr\App\Controllers\ManageDiscount')) { | |
$manage_discount = new \Wdr\App\Controllers\ManageDiscount (); //Create new object | |
foreach ($items as $key => $item) { //loop | |
$discount_details = $item->get_meta('_advanced_woo_discount_item_total_discount');// Discount Details | |
if (!empty($discount_details)) { | |
$discount = $manage_discount->getDiscountPerItem($discount_details); //Discount | |
} | |
} | |
} |
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_check_condition', '__return_true'); | |
add_filter('advanced_woo_discount_rules_is_conditions_passed', function($result, $rule_object, $rule){ | |
$conditions = $rule_object->getConditions(); | |
$rule_id = $rule_object->getId(); | |
if(in_array($rule_id, array(1, 2))){ | |
//Your custom logics enter here and return true or false | |
//true -> Run rule | |
//false -> Do not run rule |
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_strikeout_price_html', function($html, $original_price, $discounted_price, $is_variable_product, $initial_price_html, $separator){ | |
if($initial_price_html){ | |
$html = '<ins>' . $discounted_price . '</ins>'. $separator .'<del>' . $initial_price_html . '</del>' ; | |
}else{ | |
$html = '<ins>' . $discounted_price . '</ins>'. $separator .'<del>' . $original_price . '</del>' ; | |
} | |
return $html; | |
}, 10, 6); |
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_filter_passed', function ($filter_passed, $rule, $product, $sale_badge) { | |
//'array(1,2)' - give rule id as you needed | |
if (in_array($rule->getId(), array(1, 2)) && class_exists('\Wdr\App\Helpers\Woocommerce')) { | |
$rule_filter = $rule->getFilter(); | |
$product_id = \Wdr\App\Helpers\Woocommerce::getProductId($product); | |
$product_parent = \Wdr\App\Helpers\Woocommerce::getProductParentId($product_id); | |
$product_id = !empty($product_parent) ? $product_parent : $product_id; | |
$categories = \Wdr\App\Helpers\Woocommerce::getProductCategories($product); | |
$category_id = $product_tag_ids = $tag_ids = array(); | |
if ($rule_filter) { |
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('woocommerce_before_cart', function (){ | |
if (!WC()->cart->is_empty()){ | |
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_filter('advanced_woo_discount_rules_apply_coupon_for_products_based_on_filters', '__return_false'); |