Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #673143

    Hey,

    As a lot of people, I have the problem that, when I use the avia builder on a woocommerce single product page, I can use the “Product Purchase Button”, but it does not display the product price.

    Now, I tried the woocommerce shortcode, but it outputs a purchase button that looks kinda misaligned. Also, whit this one I cannot edit quantity needed. (see image – the upper part is the avia element, lower part the shortcode output)

    screenshot

    Principally, I very much prefer the purchase button style that the avia builder element gives me, but why did you guys not include price with it? Or at least an option to have a price displayed if wanted? …I mean, its a shop. Why the heck leave out the prices?!
    Anyway, I don’t wanna end up having to update all the prices on my product pages manually at times when I offer a discount or something.

    So my questions are:

    – Meanwhile, have there appeared any solutions for the problem with the avia add-to-cart-button element?
    – If not, can you tell me how to fix the button that the woocommerce shortcode gives me? Essentially, I want it to look and behave exactly as the one from the avia element, but also displaying the current price.

    • This topic was modified 8 years, 4 months ago by Robert.
    #674162

    ….hello? …anybody? =D

    #674936

    Hi,

    The avia_sc_produc_button shortcode is just a wrapper for a WooCommerce function, which only shows an add-to-cart button, one thing you could use is a price shortcode, you can add this to your functions.php:

    function wc_price_func( ) {
    
        $html = '';
    
        if( function_exists( 'wc_get_product' ) ){
             $_product = wc_get_product( get_the_ID() );
             $html = $_product->get_price();
        }
        return $html;
    }
    add_shortcode( 'woocommerce_price', 'wc_price_func' );

    Usage:

    [woocommerce_price]
    

    Best regards,
    Josue

    #675353

    Thanks!!

    This is what I’ve been looking for.
    However, there’s one more small thing: I don’t know php, but I assume $html is the variable that returns the price? Can you add a line that replaces the decimal separator “.” in the string with a “,”? The shop is in Germany.

    #675364

    Hi,

    Sure:

    function wc_price_func( ) {
    
        $html = '';
    
        if( function_exists( 'wc_get_product' ) ){
             $_product = wc_get_product( get_the_ID() );
             $html = str_replace('.',',',$_product->get_price());
        }
        return $html;
    }
    add_shortcode( 'woocommerce_price', 'wc_price_func' );
    

    Best regards,
    Josue

    • This reply was modified 8 years, 4 months ago by Josue.
    #676137

    Thanks a lot!
    Problems solved, topic closed.

    #676792

    Hi,

    Great, glad you got it working :-)

    Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘"Add to cart" button shortcode problem’ is closed to new replies.