function vtprd_get_cart_html_prices($called_from, $catalog_or_inline = null) { //v1.1.1 changed to parameter name global $post, $wpdb, $woocommerce, $vtprd_cart, $vtprd_cart_item, $vtprd_info, $vtprd_setup_options, $vtprd_rules_set; //error_log( print_r( 'vtprd_get_cart_html_prices', true ) ); $price_display_suffix = ''; //v1.0.9.3 //v1.1.1 begin if ($called_from == 'single') { $number_of_times = 1; } else { $number_of_times = sizeof($vtprd_cart->cart_items); } //v1.1.1 end for ($z = 0; $z < $number_of_times; $z++) { $product_id = $vtprd_cart->cart_items[$z]->product_id; //need this on both sides of the if if ($vtprd_cart->cart_items[$z]->yousave_total_amt > 0) { // $product_id = $vtprd_cart->cart_items[$z]->product_id; $list_price = $vtprd_cart->cart_items[$z]->db_unit_price_list; $db_unit_price_list_html_woo = woocommerce_price($list_price); $product_list_price_catalog_correctly_taxed = $list_price; //v1.1.1 //NEW UNIT PRICE ( $vtprd_cart->cart_items[$z]->discount_price = units subtotal including discount ) //$discount_price = round($vtprd_cart->cart_items[$z]->discount_price / $vtprd_cart->cart_items[$z]->quantity , 2); $discount_price = $vtprd_cart->cart_items[$z]->discount_unit_price; //v1.1.1 //v1.0.9.3 begin //v1.1.1 begin - reconfigured if ($called_from == 'single') { if (isset($_SESSION['vtprd_product_old_price_' . $product_id])) { $oldprice = $_SESSION['vtprd_product_old_price_' . $product_id]['single_product_current_price']; $oldprice_formatted = wc_price($oldprice); } else { //v1.1.0.4 begin - replace with status test if ($vtprd_cart->cart_items[$z]->product_is_on_special == 'yes') { /* if ( ($vtprd_cart->cart_items[$z]->db_unit_price_special > 0 ) && ($vtprd_cart->cart_items[$z]->db_unit_price_special < $vtprd_cart_item->db_unit_price_list) ) { */ //v1.1.0.4 end $oldprice_formatted = wc_price($vtprd_cart->cart_items[$z]->db_unit_price_special); $oldprice = $vtprd_cart->cart_items[$z]->db_unit_price_special; } else { $oldprice_formatted = wc_price($vtprd_cart->cart_items[$z]->db_unit_price_list); $oldprice = $vtprd_cart->cart_items[$z]->db_unit_price_list; } $oldprice_formatted = wc_price($oldprice); //v1.1.1 } } else { $oldprice = $_SESSION['vtprd_orig_cart_price_' . $vtprd_cart->cart_items[$z]->cart_item_key]; $oldprice_formatted = wc_price($oldprice); } $vtprd_cart->cart_items[$z]->product_catalog_price_displayed = $oldprice; $product = get_product($product_id); // $vtprd_cart->cart_items[$z]->product_catalog_price_displayed_incl_tax_woo = vtprd_get_price_including_tax($product_id, $oldprice); $vtprd_cart->cart_items[$z]->product_catalog_price_displayed_incl_tax_woo = vtprd_get_price_including_tax_forced($product_id, $oldprice, $product); $vtprd_cart->cart_items[$z]->product_catalog_price_displayed_excl_tax_woo = vtprd_get_price_excluding_tax_forced($product_id, $oldprice, $product); $yousave_total_amt = $vtprd_cart->cart_items[$z]->yousave_total_amt; $vtprd_cart->cart_items[$z]->product_catalog_yousave_total_amt_incl_tax_woo = vtprd_get_price_including_tax_forced($product_id, $yousave_total_amt, $product); $vtprd_cart->cart_items[$z]->product_catalog_yousave_total_amt_excl_tax_woo = vtprd_get_price_excluding_tax_forced($product_id, $yousave_total_amt, $product); $vtprd_cart->cart_items[$z]->computation_summary = $vtprd_cart->cart_items[$z]->product_name . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '++ Computation Summary ++' . ' ' . '(may exclude tax until end...)' . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Total Product Discount = ' . $vtprd_cart->cart_items[$z]->yousave_total_amt . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Pre-Discount Unit Price = ' . $oldprice_formatted . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Unit Quantity = ' . $vtprd_cart->cart_items[$z]->quantity . '<br>'; //v1.0.9.3 //next one's kinda faked... $vtprd_cart->cart_items[$z]->computation_summary .= '- Subtotal = Quantity * Pre-Discount Unit Price = ' . $vtprd_cart->cart_items[$z]->quantity * $vtprd_cart->cart_items[$z]->product_catalog_price_displayed . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Discounted subtotal = subtotal - discount = ' . $vtprd_cart->cart_items[$z]->discount_price . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Initial discounted Unit Price = Discounted subtotal / quantity = ' . $discount_price . '<br>'; //v1.0.9.3 //v1.0.9.3 end //Test New Unit price for rounding error and fix if ($vtprd_setup_options['discount_taken_where'] == 'discountUnitPrice') { //v1.1.0.5 begin FIX floating point error ==>> value comparison was not working due to floating point number precision //$test_total_discount_price = $discount_price * $vtprd_cart->cart_items[$z]->quantity; $test_total_discount_price = round($discount_price * $vtprd_cart->cart_items[$z]->quantity, 2); $vtprd_cart->cart_items[$z]->discount_price = round($vtprd_cart->cart_items[$z]->discount_price + 0, 2); //this fixes floating point issue... //v1.1.0.5 end $vtprd_cart->cart_items[$z]->computation_summary .= '- Test new subtotal = Initial discounted Unit Price * quantity = ' . $test_total_discount_price . '<br>'; //v1.0.9.3 switch (true) { case $test_total_discount_price == $vtprd_cart->cart_items[$z]->discount_price: $all_good; break; case $test_total_discount_price > $vtprd_cart->cart_items[$z]->discount_price: //not enough discount if ($vtprd_setup_options['give_more_or_less_discount'] == 'more') { $discount_price = $discount_price - 0.01; //smaller unit price = MORE discount $vtprd_cart->cart_items[$z]->computation_summary .= '- Test new subtotal > Discounted subtotal, and' . '<br>' . ' ' . '"give more or less discount" = more,' . '<br>' . ' ' . 'so .01 subtracted from Initial discounted Unit Price = ' . $discount_price . '<br>'; //v1.0.9.3 $test_total_discount_price = $discount_price * $vtprd_cart->cart_items[$z]->quantity; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Test new subtotal = New discounted Unit Price * quantity = ' . $test_total_discount_price . '<br>'; //v1.0.9.3 } /*else { //subtract a penny from $discount_price until $test_total_discount_price <= $vtprd_cart->cart_items[$z]->discount_price $discount_price = $discount_price + .01; //larger discount_price = larger unit price = LESS discount }*/ break; case $test_total_discount_price < $vtprd_cart->cart_items[$z]->discount_price: //too much discount if ($vtprd_setup_options['give_more_or_less_discount'] == 'more') { $all_good; } else { $discount_price = $discount_price + 0.01; //slarger unit price = LESS discount $vtprd_cart->cart_items[$z]->computation_summary .= '- Test new subtotal < Discounted subtotal, and' . '<br>' . ' ' . '"give more or less discount" = less,' . '<br>' . ' ' . 'so .01 added to Initial discounted Unit Price = ' . $discount_price . '<br>'; //v1.0.9.3 $test_total_discount_price = $discount_price * $vtprd_cart->cart_items[$z]->quantity; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Test new subtotal = New discounted Unit Price * quantity = ' . $test_total_discount_price . '<br>'; //v1.0.9.3 } break; } } $discount_price_html_woo = woocommerce_price($discount_price); //v1.0.7.4 begin $price_including_tax = vtprd_get_price_including_tax($product_id, $discount_price); $price_excluding_tax = vtprd_get_price_excluding_tax($product_id, $discount_price); $price_including_tax_html = wc_price($price_including_tax); $price_excluding_tax_html = wc_price($price_excluding_tax); $vtprd_cart->cart_items[$z]->computation_summary .= '- Final discounted Unit Price = ' . $discount_price_html_woo . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Final Unit Price including Tax = ' . $price_including_tax_html . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Final Unit Price excluding Tax = ' . $price_excluding_tax_html; //v1.0.9.3 //v1.0.7.4 end //v1.0.7 begin //from woocommerce/includes/abstracts/abstract-wc-product.php // Check for Price Suffix //v1.0.7.4 begin // no suffix processing if taxes not turned on!! global $woocommerce; if (get_option('woocommerce_calc_taxes') == 'no' || vtprd_maybe_customer_tax_exempt()) { //v1.0.7.9 $price_display_suffix = false; } else { $price_display_suffix = get_option('woocommerce_price_display_suffix'); } //v1.0.7.4 end if ($price_display_suffix && $vtprd_cart->cart_items[$z]->yousave_total_amt > 0) { //v1.0.7.2 don't do suffix for zero amount... //*************** //v1.0.7.4 begin //*************** if (strpos($price_display_suffix, '{price_including_tax}') !== false || strpos($price_display_suffix, '{price_excluding_tax}') !== false) { //does the suffix include these wildcards? // $price_including_tax = vtprd_get_price_including_tax($product_id, $discount_price); // $price_excluding_tax = vtprd_get_price_excluding_tax($product_id, $discount_price); $find = array('{price_including_tax}', '{price_excluding_tax}'); //replace the wildcards in the suffix! $replace = array($price_including_tax_html, $price_excluding_tax_html); $price_display_suffix = str_replace($find, $replace, $price_display_suffix); } //v1.0.7.4 end //then see if additonal suffix is needed if (strpos($discount_price_html_woo, $price_display_suffix) !== false) { //if suffix already in price, do nothing $do_nothing; } else { //$discount_price_html_woo = $discount_price_html_woo . ' <small class="woocommerce-price-suffix ">' . $price_display_suffix . '</small>'; $price_display_suffix = '<small class="woocommerce-price-suffix ">' . $price_display_suffix . '</small>'; } } //v1.0.7 end // $vtprd_cart->cart_items[$z]->product_catalog_discount_price_html_woo = // '<del>' . $db_unit_price_list_html_woo . '</del><ins>' . $discount_price_html_woo . '</ins>'; } else { $db_unit_price_list_html_woo = ''; $discount_price = 0; $discount_price_html_woo = ''; $price_including_tax = 0; $price_excluding_tax = 0; $price_including_tax_html = ''; $price_excluding_tax_html = ''; $product_list_price_catalog_correctly_taxed = 0; //v1.1.1 } $vtprd_cart->cart_items[$z]->product_list_price_html_woo = $db_unit_price_list_html_woo; $vtprd_cart->cart_items[$z]->product_list_price_catalog_correctly_taxed = $product_list_price_catalog_correctly_taxed; //v1.1.1 if ($catalog_or_inline == 'inline') { //load the price fields used for inline $vtprd_cart->cart_items[$z]->product_inline_discount_price_woo = $discount_price; $vtprd_cart->cart_items[$z]->product_inline_discount_price_html_woo = $discount_price_html_woo; $vtprd_cart->cart_items[$z]->product_inline_discount_price_incl_tax_woo = $price_including_tax; $vtprd_cart->cart_items[$z]->product_inline_discount_price_excl_tax_woo = $price_excluding_tax; $vtprd_cart->cart_items[$z]->product_inline_discount_price_incl_tax_html_woo = $price_including_tax_html; $vtprd_cart->cart_items[$z]->product_inline_discount_price_excl_tax_html_woo = $price_excluding_tax_html; $vtprd_cart->cart_items[$z]->product_inline_discount_price_suffix_html_woo = $price_display_suffix; } else { $vtprd_cart->cart_items[$z]->product_discount_price_woo = $discount_price; $vtprd_cart->cart_items[$z]->product_discount_price_html_woo = $discount_price_html_woo; $vtprd_cart->cart_items[$z]->product_discount_price_incl_tax_woo = $price_including_tax; $vtprd_cart->cart_items[$z]->product_discount_price_excl_tax_woo = $price_excluding_tax; $vtprd_cart->cart_items[$z]->product_discount_price_incl_tax_html_woo = $price_including_tax_html; $vtprd_cart->cart_items[$z]->product_discount_price_excl_tax_html_woo = $price_excluding_tax_html; $vtprd_cart->cart_items[$z]->product_discount_price_suffix_html_woo = $price_display_suffix; } } //end foreach return; }
public function vtprd_get_taxation_price_cart($product_id, $price) { //error_log( print_r( 'Function begin - vtprd_choose_discount_price', true ) ); global $vtprd_info, $vtprd_setup_options, $woocommerce, $vtprd_cart; if (get_option('woocommerce_calc_taxes') == 'yes') { $woocommerce_tax_display_cart = get_option('woocommerce_tax_display_cart'); $product = get_product($product_id); if (get_option('woocommerce_prices_include_tax') == 'yes') { switch (true) { // case ( $woocommerce->customer->is_vat_exempt()): case vtprd_maybe_customer_tax_exempt(): $price = vtprd_get_price_excluding_tax_forced($product_id, $price, $product); break; case $woocommerce_tax_display_cart == 'incl': //all good, nothing to do break; case $woocommerce_tax_display_cart == 'excl': $price = vtprd_get_price_excluding_tax_forced($product_id, $price, $product); break; } } else { switch (true) { case vtprd_maybe_customer_tax_exempt(): //all good, nothing to do break; case $woocommerce_tax_display_cart == 'incl': $price = vtprd_get_price_including_tax_forced($product_id, $price, $product); break; case $woocommerce_tax_display_cart == 'excl': //all good, nothing to do break; } } } return $price; }
function vtprd_get_cart_html_prices($number_of_times, $catalog_or_inline = null) { global $post, $wpdb, $woocommerce, $vtprd_cart, $vtprd_cart_item, $vtprd_info, $vtprd_setup_options, $vtprd_rules_set; //error_log( print_r( 'vtprd_get_cart_html_prices', true ) ); //error_log( print_r( '$vtprd_cart= ' , true ) ); //error_log( var_export($vtprd_cart, true ) ); $price_display_suffix = ''; //v1.0.9.3 for ($z = 0; $z < $number_of_times; $z++) { $product_id = $vtprd_cart->cart_items[$z]->product_id; //need this on both sides of the if //error_log( print_r( 'product_id= ' .$product_id, true ) ); if ($vtprd_cart->cart_items[$z]->yousave_total_amt > 0) { // $product_id = $vtprd_cart->cart_items[$z]->product_id; $list_price = $vtprd_cart->cart_items[$z]->db_unit_price_list; $db_unit_price_list_html_woo = woocommerce_price($list_price); //NEW UNIT PRICE ( $vtprd_cart->cart_items[$z]->discount_price = units subtotal including discount ) $discount_price = round($vtprd_cart->cart_items[$z]->discount_price / $vtprd_cart->cart_items[$z]->quantity, 2); //mwntest //v1.0.9.3 begin if (isset($_SESSION['vtprd_product_old_price_' . $product_id])) { $oldprice_formatted = stripslashes($_SESSION['vtprd_product_old_price_' . $product_id]); //this is FORMATTED //check del/ins in oldprice if (strpos($oldprice_formatted, '</del>') !== false) { //BOOLEAN == true... //strip out everything up to and including '<ins>', strip out </ins> // place result into $oldPrice //splits string on <ins>, removes <ins> $oldPrice_array1 = explode('<ins>', $oldprice_formatted); //this removes the delimiter string... //splits string on </ins>, removes </ins> (we will work on the 2nd half of original string) $oldPrice_array2 = explode('</ins>', $oldPrice_array1[1]); //this removes the delimiter string... $oldprice_formatted = $oldPrice_array2[0]; } $currency_symbol = get_woocommerce_currency_symbol(); //strip out currency symbol $oldprice = str_replace($currency_symbol, '', $oldprice_formatted); //********************************* //v1.0.9.5 begin - crossout price fix for using different decimal/thousands separators //strip out thousands separator ==>>(getting it this way covers pre-2.3 versions...) $thousands_sep = wp_specialchars_decode(stripslashes(get_option('woocommerce_price_thousand_sep')), ENT_QUOTES); $oldprice = str_replace($thousands_sep, '', $oldprice); //reformat into decimal as needed if decimal separator not "." AND turn decimal into floatval $oldprice = wc_format_decimal($oldprice, 2); //v1.0.9.5 end //********************************* } else { //v1.1.0.4 begin - replace with status test if ($vtprd_cart->cart_items[$z]->product_is_on_special == 'yes') { /* if ( ($vtprd_cart->cart_items[$z]->db_unit_price_special > 0 ) && ($vtprd_cart->cart_items[$z]->db_unit_price_special < $vtprd_cart_item->db_unit_price_list) ) { */ //v1.1.0.4 end $oldprice_formatted = wc_price($vtprd_cart->cart_items[$z]->db_unit_price_special); $oldprice = $vtprd_cart->cart_items[$z]->db_unit_price_special; } else { $oldprice_formatted = wc_price($vtprd_cart->cart_items[$z]->db_unit_price_list); $oldprice = $vtprd_cart->cart_items[$z]->db_unit_price_list; } } $vtprd_cart->cart_items[$z]->product_catalog_price_displayed = $oldprice; $product = get_product($product_id); // $vtprd_cart->cart_items[$z]->product_catalog_price_displayed_incl_tax_woo = vtprd_get_price_including_tax($product_id, $oldprice); $vtprd_cart->cart_items[$z]->product_catalog_price_displayed_incl_tax_woo = vtprd_get_price_including_tax_forced($product_id, $oldprice, $product); $vtprd_cart->cart_items[$z]->product_catalog_price_displayed_excl_tax_woo = vtprd_get_price_excluding_tax_forced($product_id, $oldprice, $product); $yousave_total_amt = $vtprd_cart->cart_items[$z]->yousave_total_amt; $vtprd_cart->cart_items[$z]->product_catalog_yousave_total_amt_incl_tax_woo = vtprd_get_price_including_tax_forced($product_id, $yousave_total_amt, $product); $vtprd_cart->cart_items[$z]->product_catalog_yousave_total_amt_excl_tax_woo = vtprd_get_price_excluding_tax_forced($product_id, $yousave_total_amt, $product); $vtprd_cart->cart_items[$z]->computation_summary = $vtprd_cart->cart_items[$z]->product_name . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '++ Computation Summary ++' . ' ' . '(may exclude tax until end...)' . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Total Product Discount = ' . $vtprd_cart->cart_items[$z]->yousave_total_amt . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Pre-Discount Unit Price = ' . $oldprice_formatted . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Unit Quantity = ' . $vtprd_cart->cart_items[$z]->quantity . '<br>'; //v1.0.9.3 //next one's kinda faked... $vtprd_cart->cart_items[$z]->computation_summary .= '- Subtotal = Quantity * Pre-Discount Unit Price = ' . $vtprd_cart->cart_items[$z]->quantity * $vtprd_cart->cart_items[$z]->product_catalog_price_displayed . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Discounted subtotal = subtotal - discount = ' . $vtprd_cart->cart_items[$z]->discount_price . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Initial discounted Unit Price = Discounted subtotal / quantity = ' . $discount_price . '<br>'; //v1.0.9.3 //v1.0.9.3 end //Test New Unit price for rounding error and fix if ($vtprd_setup_options['discount_taken_where'] == 'discountUnitPrice') { //v1.1.0.5 begin FIX floating point error ==>> value comparison was not working due to floating point number precision //$test_total_discount_price = $discount_price * $vtprd_cart->cart_items[$z]->quantity; $test_total_discount_price = round($discount_price * $vtprd_cart->cart_items[$z]->quantity, 2); $vtprd_cart->cart_items[$z]->discount_price = round($vtprd_cart->cart_items[$z]->discount_price + 0, 2); //this fixes floating point issue... //v1.1.0.5 end $vtprd_cart->cart_items[$z]->computation_summary .= '- Test new subtotal = Initial discounted Unit Price * quantity = ' . $test_total_discount_price . '<br>'; //v1.0.9.3 switch (true) { case $test_total_discount_price == $vtprd_cart->cart_items[$z]->discount_price: $all_good; break; case $test_total_discount_price > $vtprd_cart->cart_items[$z]->discount_price: //not enough discount if ($vtprd_setup_options['give_more_or_less_discount'] == 'more') { $discount_price = $discount_price - 0.01; //smaller unit price = MORE discount $vtprd_cart->cart_items[$z]->computation_summary .= '- Test new subtotal > Discounted subtotal, and' . '<br>' . ' ' . '"give more or less discount" = more,' . '<br>' . ' ' . 'so .01 subtracted from Initial discounted Unit Price = ' . $discount_price . '<br>'; //v1.0.9.3 $test_total_discount_price = $discount_price * $vtprd_cart->cart_items[$z]->quantity; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Test new subtotal = New discounted Unit Price * quantity = ' . $test_total_discount_price . '<br>'; //v1.0.9.3 } /*else { //subtract a penny from $discount_price until $test_total_discount_price <= $vtprd_cart->cart_items[$z]->discount_price $discount_price = $discount_price + .01; //larger discount_price = larger unit price = LESS discount }*/ break; case $test_total_discount_price < $vtprd_cart->cart_items[$z]->discount_price: //too much discount if ($vtprd_setup_options['give_more_or_less_discount'] == 'more') { $all_good; } else { $discount_price = $discount_price + 0.01; //slarger unit price = LESS discount $vtprd_cart->cart_items[$z]->computation_summary .= '- Test new subtotal < Discounted subtotal, and' . '<br>' . ' ' . '"give more or less discount" = less,' . '<br>' . ' ' . 'so .01 added to Initial discounted Unit Price = ' . $discount_price . '<br>'; //v1.0.9.3 $test_total_discount_price = $discount_price * $vtprd_cart->cart_items[$z]->quantity; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Test new subtotal = New discounted Unit Price * quantity = ' . $test_total_discount_price . '<br>'; //v1.0.9.3 } break; } } $discount_price_html_woo = woocommerce_price($discount_price); //v1.0.7.4 begin $price_including_tax = vtprd_get_price_including_tax($product_id, $discount_price); //error_log( print_r( 'vtprd_get_price_including_tax 001, price= ' .$price_including_tax , true ) ); $price_excluding_tax = vtprd_get_price_excluding_tax($product_id, $discount_price); $price_including_tax_html = wc_price($price_including_tax); $price_excluding_tax_html = wc_price($price_excluding_tax); $vtprd_cart->cart_items[$z]->computation_summary .= '- Final discounted Unit Price = ' . $discount_price_html_woo . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Final Unit Price including Tax = ' . $price_including_tax_html . '<br>'; //v1.0.9.3 $vtprd_cart->cart_items[$z]->computation_summary .= '- Final Unit Price excluding Tax = ' . $price_excluding_tax_html; //v1.0.9.3 //v1.0.7.4 end //v1.0.7 begin //from woocommerce/includes/abstracts/abstract-wc-product.php // Check for Price Suffix //v1.0.7.4 begin // no suffix processing if taxes not turned on!! global $woocommerce; if (get_option('woocommerce_calc_taxes') == 'no' || vtprd_maybe_customer_tax_exempt()) { //v1.0.7.9 $price_display_suffix = false; //error_log( print_r( 'suffix false', true ) ); } else { $price_display_suffix = get_option('woocommerce_price_display_suffix'); } //v1.0.7.4 end //$yousave_total_amt = $vtprd_cart->cart_items[$z]->yousave_total_amt; //error_log( print_r( 'yousave_total_amt' .$yousave_total_amt, true ) ); if ($price_display_suffix && $vtprd_cart->cart_items[$z]->yousave_total_amt > 0) { //v1.0.7.2 don't do suffix for zero amount... //*************** //v1.0.7.4 begin //*************** if (strpos($price_display_suffix, '{price_including_tax}') !== false || strpos($price_display_suffix, '{price_excluding_tax}') !== false) { //does the suffix include these wildcards? // $price_including_tax = vtprd_get_price_including_tax($product_id, $discount_price); // $price_excluding_tax = vtprd_get_price_excluding_tax($product_id, $discount_price); $find = array('{price_including_tax}', '{price_excluding_tax}'); //replace the wildcards in the suffix! $replace = array($price_including_tax_html, $price_excluding_tax_html); $price_display_suffix = str_replace($find, $replace, $price_display_suffix); } //v1.0.7.4 end //then see if additonal suffix is needed if (strpos($discount_price_html_woo, $price_display_suffix) !== false) { //if suffix already in price, do nothing $do_nothing; } else { //$discount_price_html_woo = $discount_price_html_woo . ' <small class="woocommerce-price-suffix ">' . $price_display_suffix . '</small>'; $price_display_suffix = '<small class="woocommerce-price-suffix ">' . $price_display_suffix . '</small>'; } } //v1.0.7 end // $vtprd_cart->cart_items[$z]->product_catalog_discount_price_html_woo = // '<del>' . $db_unit_price_list_html_woo . '</del><ins>' . $discount_price_html_woo . '</ins>'; } else { $db_unit_price_list_html_woo = ''; $discount_price = 0; $discount_price_html_woo = ''; $price_including_tax = 0; $price_excluding_tax = 0; $price_including_tax_html = ''; $price_excluding_tax_html = ''; //get the suffix for non-discounted pricing also!! // global $product; // $product = get_product( $product_id ); // $price_display_suffix = $product->get_price_suffix(); //error_log( print_r( 'suffix is zero', true ) ); //error_log( print_r( 'yousave_total_amt <= 0, all discounts zeroed', true ) ); } $vtprd_cart->cart_items[$z]->product_list_price_html_woo = $db_unit_price_list_html_woo; //error_log( print_r( '$price_display_suffix= ' .$price_display_suffix, true ) ); if ($catalog_or_inline == 'inline') { //load the price fields used for inline $vtprd_cart->cart_items[$z]->product_inline_discount_price_woo = $discount_price; $vtprd_cart->cart_items[$z]->product_inline_discount_price_html_woo = $discount_price_html_woo; $vtprd_cart->cart_items[$z]->product_inline_discount_price_incl_tax_woo = $price_including_tax; $vtprd_cart->cart_items[$z]->product_inline_discount_price_excl_tax_woo = $price_excluding_tax; $vtprd_cart->cart_items[$z]->product_inline_discount_price_incl_tax_html_woo = $price_including_tax_html; $vtprd_cart->cart_items[$z]->product_inline_discount_price_excl_tax_html_woo = $price_excluding_tax_html; $vtprd_cart->cart_items[$z]->product_inline_discount_price_suffix_html_woo = $price_display_suffix; } else { $vtprd_cart->cart_items[$z]->product_discount_price_woo = $discount_price; $vtprd_cart->cart_items[$z]->product_discount_price_html_woo = $discount_price_html_woo; $vtprd_cart->cart_items[$z]->product_discount_price_incl_tax_woo = $price_including_tax; $vtprd_cart->cart_items[$z]->product_discount_price_excl_tax_woo = $price_excluding_tax; $vtprd_cart->cart_items[$z]->product_discount_price_incl_tax_html_woo = $price_including_tax_html; $vtprd_cart->cart_items[$z]->product_discount_price_excl_tax_html_woo = $price_excluding_tax_html; $vtprd_cart->cart_items[$z]->product_discount_price_suffix_html_woo = $price_display_suffix; } //error_log( print_r( '$vtprd_cart->cart_items[$z] out of vtprd_get_cart_html_prices', true ) ); //$cart_item_for_log = $vtprd_cart->cart_items[$z]; //error_log( var_export($cart_item_for_log, true ) ); } //end foreach return; }