✏️ 编辑:woocommerce-functions.php
路径:
/home/forge/kingkrunch.com/wp/wp-content/themes/foodstuff/templatemela/woocommerce-functions.php
大小:1.81 KB · 修改:2020-09-11 16:13:49 · 权限:0775 · 可写
← 返回目录
👁 查看
⬇ 下载
<?php // Add woocommerce support theme add_action( 'after_setup_theme', 'woocommerce_support' ); function woocommerce_support() { add_theme_support( 'woocommerce' ); } // Disables woocommerce style add_filter( 'woocommerce_enqueue_styles', '__return_false' ); // Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php) add_filter('woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment'); function woocommerce_header_add_to_cart_fragment( $fragments ) { global $woocommerce; ob_start(); ?> <a class="cart-contents" href="<?php echo esc_url($woocommerce->cart->get_cart_url()); ?>" title="<?php esc_html_e('View your shopping cart', 'foodstuff'); ?>"><?php echo sprintf(_n('%d items', '%d items', $woocommerce->cart->cart_contents_count, 'foodstuff'), $woocommerce->cart->cart_contents_count);?></a> <?php $fragments['a.cart-contents'] = ob_get_clean(); return $fragments; } // Change the breadcrumb delimeter from '/' to '>' add_filter( 'woocommerce_breadcrumb_defaults', 'tm_change_breadcrumb_delimiter' ); function tm_change_breadcrumb_delimiter( $defaults ) { $defaults['delimiter'] = ' / '; $defaults['before'] = '<span>'; $defaults['after'] = '</span>'; return $defaults; } // Display products per page $tm_shop_items = get_option('tm_shop_items'); if (trim(get_option('tm_pagination')) == 'no') { add_filter( 'loop_shop_per_page', create_function( '$cols', 'return -1;' ) ); } else{ add_filter( 'loop_shop_per_page', create_function( '$cols', 'return '.$tm_shop_items.';' ), 20 ); } // Change number or products per row if (!function_exists('loop_columns')) { function loop_columns() { return get_option('tm_shop_items_per_row'); // products per row } } add_filter('loop_shop_columns', 'loop_columns');?>
💾 保存
取消
保存为 UTF-8,换行统一为 LF