Merhaba,
Sepete ekle butonuna basıldığında, "Sepete eklendi" yazısı yazması için böyle bir kod kullanıyorum.
/**
* @snippet       Change "Add to Cart" Button Label if Product Already @ Cart
* @how-to        Get CustomizeWoo.com FREE
* @author        Rodolfo Melogli
* @compatible    WC 5.0
* @donate $9     https://businessbloomer.com/bloomer-armada/
*/
 
// Part 1
// Single Product Page Add to Cart
 
add_filter( 'woocommerce_product_single_add_to_cart_text', 'bbloomer_custom_add_cart_button_single_product', 9999 );
 
function bbloomer_custom_add_cart_button_single_product( $label ) {
   if ( WC()->cart && ! WC()->cart->is_empty() ) {
      foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
         $product = $values['data'];
         if ( get_the_ID() == $product->get_id() ) {
            $label = 'Sepete Eklendi';
            break;
         }
      }
   }
   return $label;
}
 
// Part 2
// Loop Pages Add to Cart
 
add_filter( 'woocommerce_product_add_to_cart_text', 'bbloomer_custom_add_cart_button_loop', 9999, 2 );
 
function bbloomer_custom_add_cart_button_loop( $label, $product ) {
   if ( $product->get_type() == 'simple' && $product->is_purchasable() && $product->is_in_stock() ) {
      if ( WC()->cart && ! WC()->cart->is_empty() ) {
         foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
            $_product = $values['data'];
            if ( get_the_ID() == $_product->get_id() ) {
               $label = 'Sepete Eklendi';
               break;
            }
         }
      }
   }
   return $label;
}
ama sayfa yenilendiğinde çalışıyor anlık sepete ekle dendiğinde yazı değişmiyor. Anlayan arkadaşlar yardımcı olabilir mi ?