Which hook should I use to capture $_POST(‘password’) via profile update and password reset

Sometimes you have to look at the name of the input you’re trying to pick up via $_POST. It’s not always consistent across forms. In the case of the WooCommerce password change form, the input name for the new password field is ‘password_1’ so that’s what you need to pick up via $_POST: function my_profile_update( … Read more

How to hide out of stock products in Related Products via custom query in WooCommerce

Figured it out. None of the blog posts out there are accurate it seems. Put this in your functions.php file. You can change the posts per page number to see if its working straight away or not. add_filter( ‘woocommerce_output_related_products_args’, function( $args ) { $args = wp_parse_args( array( ‘posts_per_page’ => 4, ‘meta_query’ => array ( ‘key’ … Read more

Display description on cart page

$_product object is product variation object. You have to first get the parent product id and then get the description of parent product. $parent_product_id =$_product->get_parent_id(); $parent_product = get_post($parent_product_id); echo $content = $parent_product->post_content; Or echo $_product->parent->description;

Filter WooCommerce Orders query with user meta data

I see 2 possible ways: 1) Using your WP_User_Query in a WC_Order_Query with the customer_id argument this way: // Users query $user_ids = (array) get_users([ ‘role’ => ‘customer’, ‘number’ => – 1, ‘fields’ => ‘ID’, ‘meta_query’ => [ ‘relation’ => ‘OR’, [ ‘key’ => ‘unsubscribed’, ‘compare’ => ‘!=’, ‘value’ => 1 ], [ ‘key’ => … Read more

Get rid of product images mobile swipe functionality from WooCommerce single product [closed]

Everything required is located on Class WC_Frontend_Scripts source code: To target mobile devices, you can use the WordPress conditional tag wp_is_mobile(). A) For the Photoswipe functionality you have essentially 2 hooks: woocommerce_single_product_photoswipe_enabled to disable it. woocommerce_single_product_photoswipe_options to change options (see below). 1) To disable it, you will use: add_filter( ‘woocommerce_single_product_photoswipe_enabled’, ‘__return_false’ ); or targeting mobile … Read more

Remove Order List Row Link in WooCommerce Admin?

Based on class-wc-admin-list-table-orders.php (order column on line 173) there doesn’t seem to be a filter to change the markup. To circumvent this, perhaps you could add a js/jQuery script, to admin_footer or with admin_enqueue_scripts, which either adds the necessary class(es), removes href or changes it to #, or with some event delegation wizardry have your … Read more

Woocommerce – Override the default templates location under the theme directory

I believe you can use the woocommerce_template_path hook/filter: // $path defaults to ‘woocommerce/’ (in your theme folder) add_filter( ‘woocommerce_template_path’, function( $path ){ $my_path = get_stylesheet_directory() . ‘/plugins/woocommerce/’; return file_exists( $my_path ) ? ‘plugins/woocommerce/’ : $path; } ); It should work whether you’re overriding only specific files or all — i.e. you copy all files and … Read more

Update html tag class values based on Woocommerce product attribute dropdown selection [closed]

You can use the following to add/remove a customized class to #primary selector based on the selected product attribute “Color”: <script type=”text/javascript”> jQuery(function($){ var p = ‘#primary’, c = $(p).prop(‘class’), s=”select[name=”attribute_pa_color”]”; // On start if( $(s).val() !== ” ) { $(p).prop(‘class’, ‘background-‘+$(s).val()); } // On select (blur live event) $(s).blur( function() { var b = … Read more