WooCommerce – Multiple meta query not working

meta_query format and orderby format should be as follows: $args = array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘posts_per_page’=> 10, ‘orderby’ => ‘total_sales’, ‘order’ => ‘DESC’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘_featured’, ‘value’ => ‘yes’, ‘compare’ => ‘=’ ), array( ‘key’ => ‘total_sales’, ‘value’ => ’10’, ‘compare’ => ‘>=’ ) ) … Read more

Delete All Product Images in phpmyadmin

You can loop through all the woo-commerce products and delete them along with their attachment(images).. $args = array( ‘post_type’ => ‘product’, … ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php wp_delete_post( $loop->post->ID ); wp_delete_attachment( $loop->post->attachment_id ); ?> <?php endwhile; ?>

WooCommerce – Display nested list of all subcategories on archive-product.php

I solved this by modifying the function linked to in the question to make it recursive. The comments explain my changes: function woocommerce_subcats_from_parentcat_by_ID( $parent_cat_ID ) { $args = array( ‘hierarchical’ => 1, ‘show_option_none’ => ”, ‘hide_empty’ => 0, ‘parent’ => $parent_cat_ID, ‘taxonomy’ => ‘product_cat’ ); $subcats = get_categories($args); if ( $subcats ) { // added … Read more

Woocommerce – Show random product thumbnail from specific product category

Add a tax_query to your $args… $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, //possible values are term_id, name, slug or term_taxonomy_id ‘terms’ => ‘tshirt’ //can be single string or array of slugs, names, term_ids or taxonomy_ids ) ) ); $results = get_posts( $args ); Recommended reading: https://codex.wordpress.org/Template_Tags/get_posts#Taxonomy_Parameters http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

wp_customize – detect post type to show/hide customizer options

Customizer Controls can be displayed based on context. With active_callback API introduced in WordPres 4.0, you can control where to show your specific options. Add your customizer options like this with the optional active_callback argument. $wp_customize->add_control( ‘wc_cart_page_option’, array( ‘label’ => esc_html__( ‘Cart Page Options’ ), ‘section’ => ‘wc_cart’, ‘active_callback’ => ‘estore_is_cart’, )); Now create a … Read more

Remove the link from the thumbnail and product title on woocommerce

It’s a bit hard to tell without knowing what shop theme you are using but I’ll try anyways…  The code <?php wc_get_template_part( ‘content’, ‘product’ ); ?> is basically calling the template file content-product.php. I would however not recommend you alter the default file. On a standard woocommerce install you will find that default template file … Read more

How to change a column width on WooCommerce orders page (Admin)

To set a different column width for the Ship to, add this to your functions.php: add_action( ‘admin_head’, ‘wpse_237354_ship_to_column’ ); function wpse_237354_ship_to_column() { global $pagenow; if ( $pagenow == ‘edit.php’ ) { ?> <style type=”text/css”> .manage-column.column-shipping_address { width: 10px; } </style> <?php } } This adds custom CSS in the header page with your new column … Read more