2016-08-19 5 views
1

После нажатия на кнопку Добавить в корзину У меня есть сообщение -WooCommerce сообщение крюк после добавления в корзину

«название продукта» добавлен в корзину успешно.

ПЕРЕД ПРОДУКЦИИ, я хочу добавить еще один пользовательское сообщение (для справки я добавил скриншот).

Какой крючок следует использовать?

ответ

2

Попробуйте это.

/** 
* Custom Add To Cart Messages 
* Add this to your theme functions.php file 
**/ 
add_filter('wc_add_to_cart_message', 'custom_add_to_cart_message'); 
function custom_add_to_cart_message() { 
    global $woocommerce; 
    // Output success messages 
    if (get_option('woocommerce_cart_redirect_after_add')=='yes') : 
     $return_to = get_permalink(woocommerce_get_page_id('shop')); 
     $message = sprintf('<a href="%s" class="button">%s</a> %s', $return_to, __('Continue Shopping &rarr;', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce')); 
    else : 
     $message = sprintf('<a href="%s" class="button">%s</a> %s', get_permalink(woocommerce_get_page_id('cart')), __('View Cart &rarr;', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce')); 
    endif; 
     return $message; 
} 
/* Custom Add To Cart Messages */ 

Reference

0

Здесь вы можете попробовать этот крюк:

https://therichpost.com/cart-notices-woocommerce 

Надеется, что это поможет вам ..

Смежные вопросы