Site logo

Archived topic

Hello, i need help with - Display cart panel on add to cart.

17 replies · Started by Alon on October 21, 2022

Viewing posts 16–18 of 18

Hi Alon,

Can you try the below code instead:

function generatepress_custom_add_to_cart_panel_fragments( $fragments ) {
	if ( isset( WC()->cart ) ) {
		$fragments['.add-to-cart-panel .cart-data'] = '<div class="cart-data">' . sprintf( _n( '%d פריט', '%d פריטים', WC()->cart->get_cart_contents_count(), 'gp-premium' ), WC()->cart->get_cart_contents_count() ) . ' - ' .  WC()->cart->get_cart_total() . '</div>';
	}

	return $fragments;
}

function cart_panel_text_strings( $translated_text, $text, $domain ) {
	$domain ='gp-premium';
    switch ( $translated_text ) {
        case 'Checkout' :
            $translated_text = 'לתשלום בקופה';
            break;
        case 'Continue Shopping' :
            $translated_text = 'המשך קניות';
            break;
        case 'Item added to cart.' :
            $translated_text = 'פריט נוסף לסל קניות';
            break;
    }
    return $translated_text;
}
add_filter( 'gettext', 'cart_panel_text_strings', 20, 3 );
add_filter( 'woocommerce_add_to_cart_fragments', 'generatepress_custom_add_to_cart_panel_fragments', 10, 1 );

Let me know if it works :)

OOOHHHHHHH GREAT.
Thank you and David for your great help.
:O)

You are welcome :)

This archived topic is closed to new replies.