This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Automatically Delete Woocommerce Images After Deleting a Product | |
add_action( 'before_delete_post', 'delete_product_images', 10, 1 ); | |
function delete_product_images( $post_id ) { | |
// Check if user has the capability to delete products | |
if ( !current_user_can( 'delete_products' ) ) { | |
return; | |
} | |
$product = wc_get_product( $post_id ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_function_name() { | |
$workflow = AutomateWoo\Workflows::get_current(); | |
if ( $workflow ) { | |
$customer_id = $workflow->data_layer()->get_customer_id(); | |
// Now you can use $customer_id in your function | |
} | |
} | |
add_action( 'automatewoo/custom_functions', 'my_function_name' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Woo Forum Highlighter for .org | |
// @namespace https://woocommerce.com/ | |
// @version 1.0.28 | |
// @description Highlight threads where an a11n was the last to reply. | |
// @match https://wordpress.org/support/plugin/* | |
// @match https://wordpress.org/support/theme/* | |
// @match https://wordpress.org/support/users/* | |
// @match https://*.wordpress.org/plugins/* | |
// @downloadURL https://github.com/Automattic/support-helper-tools/raw/main/woocommerce-tools/wcforumattic.user.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_get_price_html', 'display_striked_out_price_for_variable', 200, 2); | |
function display_striked_out_price_for_variable($price='', $product) | |
{ | |
if (!$product->is_on_sale()){ | |
return $price; | |
} | |
if ($product->is_type('variable')) { | |
$variations = $product->get_available_variations(); | |
$regular_prices = array(); | |
$sale_prices = array(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_get_price_suffix', function ( $html, $product, $price, $qty ) { | |
if ( ! $html && $product instanceof WC_Product_Variable) { | |
// Copied from plugins/woocommerce/includes/abstracts/abstract-wc-product.php#get_price_suffix | |
if ( ( $suffix = get_option( 'woocommerce_price_display_suffix' ) ) | |
&& wc_tax_enabled() | |
&& 'taxable' === $product->get_tax_status() | |
) { | |
$replacements = array( | |
'{price_including_tax}' => wc_price( wc_get_price_including_tax( $product, array( 'qty' => $qty, 'price' => $price ) ) ), | |
'{price_excluding_tax}' => wc_price( wc_get_price_excluding_tax( $product, array( 'qty' => $qty, 'price' => $price ) ) ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_remove_all_quantity_fields( $return, $product ) { | |
return true; | |
} | |
add_filter ( 'woocommerce_is_sold_individually','custom_remove_all_quantity_fields', 10, 2 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_product_tabs', 'remove_additional_information_tab', 98 ); | |
function remove_additional_information_tab( $tabs ) { | |
// Check if the 'additional_information' tab is set and remove it | |
if (isset($tabs['additional_information'])) { | |
unset($tabs['additional_information']); | |
} | |
return $tabs; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// enable gutenberg for woocommerce | |
function activate_gutenberg_product( $can_edit, $post_type ) { | |
if ( $post_type == 'product' ) { | |
$can_edit = true; | |
} | |
return $can_edit; | |
} | |
add_filter( 'use_block_editor_for_post_type', 'activate_gutenberg_product', 10, 2 ); | |
// enable taxonomy fields for woocommerce with gutenberg on |