【发布时间】:2018-10-04 00:48:57
【问题描述】:
在 Woocommerce 中,我正在尝试根据其所在的产品类别更改“添加到购物车”按钮的颜色。到目前为止,我能够更改文本,但我不知道如何更改以哈希格式(例如#fffff)传入一个持久的颜色值
// Change add to cart button text per category
add_filter( 'woocommerce_product_single_add_to_cart_text', 'wps_custom_cart_button_text' );
function wps_custom_cart_button_text() {
global $product;
$terms = get_the_terms( $product->ID, 'product_cat' );
foreach ($terms as $term) {
$product_cat = $term->slug;
break;
}
switch($product_cat) {
case 'clothing';
return __('Order your Clothes', 'your_theme_text_domain' );
default;
return __( 'Order now', 'your_theme_text_domain' );
}
}
任何帮助表示赞赏。
【问题讨论】:
标签: php jquery wordpress button woocommerce