• Resolved aeonsv

    (@aeonsv)


    Hi guys, i put php snipped code in my store but i have problem and need help.

    The code show the symbol and the amount like this “You save: $20” but in my country the symbol is over the number like this “You save: 20 PLN”

    Just need to replace the value of this code but i don’t know how i try everything.

    function you_save_text_for_product() {
    global $product;

    // works for Simple and Variable type
    $regular_price     = get_post_meta( $product->get_id(), '_regular_price', true ); // 36.32
    $sale_price    = get_post_meta( $product->get_id(), '_sale_price', true ); // 24.99
    
    if( !empty($sale_price) ) {
    
        $saved_amount      = $regular_price - $sale_price;
        $currency_symbol   = get_woocommerce_currency_symbol();
    
        $percentage = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
        ?>
            <p class="you_save_price">You save: <?php echo $currency_symbol .''. number_format($saved_amount, 2, '.', ''); ?></p>           
        <?php       
    } 

    }
    add_action( ‘woocommerce_single_product_summary’, ‘you_save_text_for_product’, 12 ); // hook priority

Viewing 1 replies (of 1 total)
  • anastas10s

    (@anastas10s)

    Hi there @aeonsv ??

    Helping out with custom coding of this nature is outside the scope of support that our support staff can help out with here, although I would recommend the following:

    • Running the exact question you’re asking, along with the code provided, through an AI platform like ChatGPT for recommendations/changes to your code;
    • Joining our WooCommerce Slack community (it does have a developer channel where you can ask coding questions): https://woo.com/community-slack/

    Hope it helps!

Viewing 1 replies (of 1 total)
  • The topic ‘PHP Code for “SAVE” in product page’ is closed to new replies.