Created
September 10, 2015 21:38
-
-
Save growdev/5a6c2582807fcf4575ac to your computer and use it in GitHub Desktop.
Get Product Discounted Price
This file contains hidden or 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 | |
// add qty to cart to trigger dynamic pricing | |
$cart_item_key = WC()->cart->add_to_cart('8','300'); | |
$product = wc_get_product( '8' ); | |
echo "NAME: " . $product->get_title() . "\n"; | |
$price = $product->get_price(); | |
echo "PRICE: " . $price . "\n"; | |
/* | |
Currently this is output: | |
NAME: Dinosaur Shirt | |
PRICE: 10 | |
Expecting price to drop to 4.5 | |
*/ | |
// remove qty from cart | |
WC()->cart->remove_cart_item( $cart_item_key ); |
What is your rule configuration though? It needs to be a simple rule or an advanced rule with 0 as the starting quantity.
I think i see what your asking, for a function that you can manually pass a different quantity to to get what the discount would be at that amount?
@lucasstark
It's a simple product with some quantity price changes:
I'm not sure if that's an advanced or simple rule.
I think i see what your asking, for a function that you can manually pass a different quantity to to get what the discount would be at that amount?
Yes, exactly that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The goal is to be able to find a price given a
Product ID
andQuantity
. I'm going to run this from the WC API.