Skip to content

Instantly share code, notes, and snippets.

View Tiex84's full-sized avatar
🍹

Lorenzo De Angelis Tiex84

🍹
View GitHub Profile
@Jon007
Jon007 / functions.php
Last active December 4, 2023 08:17
Add default Product Attributes to all WooCommerce products
/*
* Example adds certain named Product Attribute fields to the product Edit screen ready for completion.
* (Pre-requisite )
* This saves the Shop Admin having to add them manually.
*
* Why might you want to do this instead of adding Custom fields? There's plenty of nice documentation on adding custom fields
* for example: http://www.remicorson.com/mastering-woocommerce-products-custom-fields/
*
* Well a Product Attributes are a built in WooCommerce feature, using Terms which are a built in Wordpress feature.
* - no add-ons required
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );