Hi
Thanks for reaching out.
Our plugin applies the discount on the fly dynamically while adding the product to the cart. However, it doesn’t change the price in the back-end.
To get a discount on a product, you can give it a try using this snippet. https://gist.github.com/AshlinRejo/c37a155a42c0e30beafbbad183f0c4e8
Hope this helps!
Thanks
Team Flycart
Thread Starter
Tim
(@timwakeling-1)
Thanks for the quick reply! 🙂
However I don’t want the discount amount; it’s a Buy One Get One Free offer. I need a function where I can input the product ID and a rule ID, and it tells me whether that rule applies to the given product – true or false?
Hi
Hi
Thank you for your response.
With the provided code snippet you can use the below line:
$return_details ='all'
This will provide you with the discount details.
Example: https://nimb.ws/kd1GwR
Hope this helps!
Thanks,
Team Flycart
Thread Starter
Tim
(@timwakeling-1)
Thanks – I’m trying that and really struggling – no matter how I query this function it always seems to return false. I’m querying it on the product page of a product that I know does qualify, because if I add the product to the cart, the offer is applied.
Here’s what I’m doing:
// Finance table and promos after "Add to cart"
add_action( 'woocommerce_after_add_to_cart_form', 'woo_finance_table_and_promos');
function woo_finance_table_and_promos(){
global $product;
$product_price = $product->get_price();
$discount = apply_filters('advanced_woo_discount_rules_get_product_discount_price_from_custom_price', $product_price, $product, 1, 0, 'all', true);
echo '<pre>' . print_r( $discount, true ) . '</pre>';
// and more that I've omitted here
}