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

Call global variable array() in woocommerce child/template

It is all fine. You just need to declare variable global first then you can set the value of this and access globally. function my_free_shipping( $is_available ) { global $woocommerce, $product_notfree_ship; // set the product ids that are $product_notfree_ship $product_notfree_ship = array( ‘1’, ‘2’, ‘3’, ‘4’, ‘5’ ); Then again declare it globally when using … 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

Delete transients in website

Transient are not always deleted when they expire, and that makes them unpredictable and sometimes a pain. Whenever I work with transients, I add some kind of functionality to delete the transients when something happens, like I delete transients when publishing posts or updating them if the transient was meant to keep data related to … Read more

Woocommerce – How to populate custom select field with stored values on checkout page?

I just had a similar problem and solved it with a combination of PHP and jQuery. If $stored_value is what you have pulled from the DB and #billing_postcode is the id of the select-tag: <?php if ( !empty( $stored_value ) ) { ?> <script type=”text/javascript”> jQuery(document).ready(function($) { $(“select#billing_postcode”).val( “<?php echo $stored_value; ?>” ); }); </script> … Read more