Site Analysis
Твиты
Афоризмы
Цитаты
Новости
Analysis

WP+Woocommerce – edit attribute table

Edit attributes Woocommerce

Default view product attributes for WooCommerce - table in tabs "Additional information". Image below - standart output attributes WooCommerce in theme WordPress twentysixteen:

 

About add and editing Woocommerce attributes i write here, this post will be about different output table attributes and editing code table attributes.

File from code table attributes (wich output tab "Additional information"):

wp-content/plugins/woocommerce/templates/single-product/product-attributes.php

Copy to:

wp-content/themes/*YOUR-THEME*/woocommerce/single-product/product-attributes.php

Default code table attributes Woocommerce 3.0.9

 

Code have two section -

  1. Output weight and dimensions;
  2. While on lists attributes product. 

 

Differents methods output table attributes

 
In order to output table attributtes other place, need disable default call template attributes and after need add code in place who must be table attributes. Make this can with the help WordPress hooks.

Attributes output in tab "Additional information", this tabs call in file "content-single-product.php", hook -

do_action( 'woocommerce_after_single_product_summary' );

Hook 'woocommerce_after_single_product_summary' well output next blocks:

  1. Up-sells products;
  2. Cross products;
  3. Tabs block.

For disable only tab "Additional information", add next code  in functions.php your theme:

Ths code have two rows disable, it rows can delete other tabs. If need delete all tabs, remove in action "woocommerce_after_single_product_summary" event "woocommerce_output_product_data_tabs":

remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs',10); 

In order that output table attributes before tabs, add next hook (priority low 10):

add_action('woocommerce_after_single_product_summary', 'woocommerce_product_additional_information_tab', 4);

When have a little attributes in products, can paste table in right block after button "Add to cart" with the help hook "woocommerce_single_product_summary" (priority more 60):

add_action('woocommerce_single_product_summary', 'woocommerce_product_additional_information_tab',70);

 

Code for output attributes table in other places woocommerce theme:

do_action( 'woocommerce_product_additional_information', $product );

Don't forget add object product in this hook. Usualy object determine at the top page current templates, but if it missing, add:

global $product;

before call hook "woocommerce_product_additional_information".

 

 

Tags:
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (8 votes, average: 9.88 out of 10)
Loading...

Leave a Reply