2016-01-29 61 views
1

我目前正在使用40k +關聯產品開發一個woocommerce網店。 下面加入購物車按鈕woocommerce自動顯示SKU,類別和標籤。不過,我想添加產品元提供的更多信息,例如尺寸,顏色和品牌。在Woocommerce產品頁面顯示更多產品元信息

我已經搞亂了Meta.php,但沒有運氣到目前爲止。 我已經嘗試添加幾個變量,例如:

現有:我添加

$cat_count = sizeof(get_the_terms($post->ID, 'product_cat')); 

$col_count = sizeof(get_the_terms($post->ID, 'product_col')); 
DIV類

「product_meta」,它規定如下:

<?php echo $product->get_categories(', ', '<span class="posted_in">' . _n('Category:', 'Categories:', $cat_count, 'woocommerce') . ' ', '</span>'); ?> 

新增:

<?php echo $product->get_colors(', ', '<span class="posted_in">' . _n('Color:', 'Colors:', $col_count, 'woocommerce') . ' ', '</span>'); ?> 

但是沒有成功。不是有經驗的編碼員,所以如果我做了一些完全愚蠢的事情,請原諒我。

隨着親切的問候,

魯迪

回答

1

例如,你可以使用產品屬性在WooCommerce:

  1. 打開 '產品' 的管理儀表板部分
  2. 打開 '屬性' 第
  3. 創建必需的屬性(例如顏色)並保存此
  4. 轉到產品編輯頁面
  5. 打開 '屬性' 選項卡,設置屬性(S)值(S)
  6. 保存產品

之後,你需要重寫WooCommerce模板文件(.../WP-內容/插件/ woocommerce /模板/單品/ meta.php)

拷貝代碼meta.php:

$attributes = $product->get_attributes(); 

foreach ($attributes as $attribute) { 

    print_r(wc_attribute_label($attribute[ 'name' ]) . ': '); 
    print_r(array_shift(wc_get_product_terms($product->id, $attribute[ 'name' ])); 

} 

更多信息添加到這裏WC店鋪頁:

https://www.skyverge.com/blog/add-information-to-woocommerce-shop-page/

相關問題