Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #2469131
Add Cart Total to the Checkout Button
Closed

Comments

  •  2
    Jonah started the conversation

    Hi. I'd like to add the cart total to the Checkout Button text in the fly cart. I want the button to read "Checkout - $X" 

    I've been working with the code below but it doesn't produce the cart total. What am I missing?


    add_filter( 'gettext', 'woofc_gettext', 99, 3 );
    function woofc_gettext( $translation, $text, $domain ) {
        
        if ( $domain === 'woofc' && $text === 'Checkout' ) {
            return 'Checkout - $' . $cart_total;
        }
        return $translation;
    }


  •  2
    Jonah replied

    I've also tried this code below but haven't been able to return the cart total within the button:


    function minicart_button_proceed_to_checkout() {

           $new_checkout_link = WC()->cart->get_checkout_url();
           $minicart_total = WC()->cart->total; 
           ?>
           <a href="<?php echo $new_checkout_link; ?>" class="woofc-action woofc-action-inner woofc-action-full">
      
      <?php _e(  'Checkout - $' . $minicart_total, 'woofc' ); ?></a>
      
    <?php
    }


  •  767
    Janilyn replied

    Hi Jonah,

    Thank you for contacting WPClever Support Forum. 

    We’ve received your ticket and assigned one of our developers to help you with that. 

    He’ll be looking into your question and responding with specific instructions as soon as possible. 

    Please stay patient as we're having very heavy workloads, it might take some time for our developers to reach back.

    Best regards.

    Janilyn T. - WPClever Support Agent

  •  1,222
    Dustin replied

    Hi Jonah,

    If you're using the free version, please change the line 869 and 878 on our-plugin-folder/wpc-fly-cart.php

    From:

    ' . esc_html__( 'Checkout', 'woofc' ) . '

    To: https://www.screencast.com/t/NaKcg0xQ

    ' . esc_html__( 'Checkout', 'woofc' ) . ' ' . WC()->cart->get_total() . '

    If you're using the premium version, you can find it on the line 928 & 937.

    Best regards,
    Dustin

  •  2
    Jonah replied

    Thanks Frankie. Is there anyway to do that in the child theme function file instead?

  •  1,222
    Dustin replied

    Currently, we haven't a filter hook at this position, so you need to change the code manually.

    We'll add it to the next updated version soon.

    Best regards,
    Dustin

  •  2
    Jonah replied

    Thanks, Frankie!


  •  1,222
    Dustin replied

    You're welcome!smile.png

    If you are satisfied with our plugin and support, please reward it with a full five-star ★★★★★ ratin.
    https://wordpress.org/support/plugin/woo-fly-cart/reviews/?filter=5
    Thank you in advance! <3

    Best regards,
    Dustin

  •  2
    Jonah replied

    Hi. As of the most recent update of the software, I believe this code needs to be modified slightly since the original snippet ['. esc_html__( 'Checkout', 'woofc' ') . ] has changed. Can somebody please help me with that?

  •  1,222
    Dustin replied

    Hi Jonah,

    In the latest version, you can change this text in the Localization tab https://www.screencast.com/t/fIhkmpcz87l

    Best regards,
    Dustin

  •  2
    Jonah replied

    Thanks, Dustin, but how do I add the cart subtotal to that checkout button?

  •  1,222
    Dustin replied

    Please add the below custom code (How to add custom code?)

    add_filter( 'woofc_localization_checkout', function () {
        return 'Checkout ' . WC()->cart->get_total();
    } );

    Best regards,
    Dustin

  •  2
    Jonah replied

    Thanks again, Dustin. I added the snippet to my themes functions file but the cart subtotal is not appearing in the flycart's checkout button. My guess is I missed something but let me know what you think.

  •  1,222
    Dustin replied

    Please ensure that you're using the latest version 4.1.0, then please update the cart (add or remove a product) to see the change.

    Best regards,
    Dustin

  •  2
    Jonah replied

    That worked, Dustin. Thank you!

  •  1,222
    Dustin replied

    You're welcome!smile.png

    Feel free to submit a new ticket if you have any questions when using our plugin.

    Best regards,
    Dustin

  •  2
    Jonah replied

    Hi. As of the most recent plugin update, this fix is no longer working. Can I get an update to the work around?

  •  1,222
    Dustin replied

    Hi Jonah,

    This snippet still works fine on my end https://www.screencast.com/t/Kg61OToe

    add_filter( 'woofc_localization_checkout', function () {
        return 'Checkout ' . WC()->cart->get_total();
    } );

    So, please send me your website credentials (wp-admin link, username, password) then I can check and fix it for you. You also can create a dev/staging site with the same configurations then I'll work on it.

    Best regards,
    Dustin

  •  2
    Jonah replied

    Thanks, Dustin! I was a victim of a self-inflicted typo. Thank you for your help!

  •  1,222
    Dustin replied

    You're welcome!smile.png

    Feel free to submit a new ticket if you have any questions when using our plugin.

    Best regards,
    Dustin