我试图显示自定义文字'如果您今天结帐,您的产品将于周日发货。' (当我的用户点击Woo上的Add To Cart按钮时)(最好是工具提示)。我该怎么做呢我重新使用的任何示例代码?
答案 0 :(得分:1)
转到以下woocommerce模板single-product\add-to-cart
目录。然后在此目录下的每个php
文件中搜索add_to_cart_button
。您将找到相关的html标签来添加自定义工具提示。
会话后更新的答案:
/**
* Custom Add To Cart Messages
* Add this to your theme functions.php file
**/
add_filter( 'wc_add_to_cart_message_html', 'woocommrece_custom_add_to_cart_message' );
function woocommrece_custom_add_to_cart_message() {
global $woocommerce;
$twoDayFromNow = date('l' , strtotime('tomorrow + 1day'));
$messageContent = 'Your product will be delivered by ' . $twoDayFromNow . ' if you checkout today';
// Output success messages
if (get_option('woocommerce_cart_redirect_after_add')=='yes') :
$return_to = get_permalink(wc_get_page_id('shop'));// Give the url, you want to redirect
$message = sprintf('<a href="%s">%s</a> %s', $return_to, __('Continue Shopping →', 'woocommerce'), __($messageContent, 'woocommerce') );
else :
$message = sprintf('<a href="%s">%s</a> %s', get_permalink(wc_get_page_id('cart')), __('View Cart →', 'woocommerce'), __($messageContent, 'woocommerce') );
endif;
return $message;
}
/* Custom Add To Cart Messages */