Skip to content

Instantly share code, notes, and snippets.

@ashwebstudio
Last active September 15, 2016 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashwebstudio/03fff9092b67bf162e8f4e1c1041d0a9 to your computer and use it in GitHub Desktop.
Save ashwebstudio/03fff9092b67bf162e8f4e1c1041d0a9 to your computer and use it in GitHub Desktop.
EDD Experiment Setup 2
$current_price_int = 149;
if ( edd_cart_has_discounts() ) {
$discounts = edd_get_cart_discounts();
$discount_code = $discounts[0];
} elseif ( isset( $_GET['discount'] ) ) {
$discount_code = $_GET['discount'];
}
if ( $discount_code ) {
$new_price = edd_get_discounted_amount( $discount_code, $current_price_int );
}
if ( $new_price ) {
$discount_price = '$' . str_replace( '.00', '', number_format( $new_price, 2 ) );
$current_price = '<span style="text-decoration: line-through">$149</span> ' . $discount_price;
} else {
$current_price = '$' . $current_price_int;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment