Why do Woocommerce templates use hooks rather than get_template_part

I’m not familiar with Woocommerce, but in short, get_template_part() only look for template parts in parent and child themes, not in plugins. If you look at the source code, get_template_part() uses locate_template which have the following source code (which is where the actual template part is searched for) function locate_template($template_names, $load = false, $require_once = … Read more

Custom Text on Product Page based on Shipping Class [closed]

To display something above the product page, hook into woocommerce_before_single_product, and to get the shipping class use the get_shipping_class() method on the product, which can be retrieved with wc_get_product(): function wpse_295878_shipping_banner() { $product = wc_get_product(); $shipping_class = $product->get_shipping_class(); switch ( $shipping_class ) { case ‘free-shipping’: echo ‘<div class=”woocommerce-info”>Free shipping on this item</div>’; break; case ‘flat-rate’: … Read more

Woocommerce products are not displayed on front-end . No products were found matching your selection [closed]

WooCommerce products have a lot of metadata. Give a look at this answer to see most of them. In your case it seems that the problem is the missing _visibility. Did you already try something like this? $item = [ ‘post_title’ => $product[‘name’], ‘post_status’ => ‘publish’, ‘post_type’ => ‘product’, ]; $postId = wp_insert_post($item); update_post_meta( $postId, … Read more

Button to update order status Woocommerce with WC Marketplace

Thank you all, I did found the answer HERE. I adapt a bit the code to my needs and added a button. html: <div> <form method=”post” name=”update_status”> <button type=”submit” name=”marked_as_completed”>Mark as Completed</button> </form> </div> php: <?php if (isset($_POST[“marked_as_completed”])) { $completed_status = $order->get_id(); $order = new WC_Order($completed_status); $order->update_status(‘completed’, ‘order_note’); echo ‘<h2 style=”color:green;”>Completato &check;</h2>’; } ?>