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

Add to checkout total lines an additional line below shipping in WooCommerce

You could use the Fee API that will create in totals line below shipping optionsCode goes in function.php file of your active child theme (or active theme). Tested and works., based on the shipping total x 1.5 (+50%), where you can include your conditional logic, like: add_action( ‘woocommerce_cart_calculate_fees’,’custom_pack_fee’, 10 , 1 ); function custom_pack_fee( $cart … Read more

Add a custom text field to WooCommerce admin product data “Variations”

Overriding core files is really something to avoid absolutely for many reasons. To add a custom field to product variations options prices and save the value on save, use this: // Admin: Add custom field in product variations options pricing add_action( ‘woocommerce_variation_options_pricing’, ‘add_variation_custom_option_pricing’, 10, 3 ); function add_variation_custom_option_pricing( $loop, $variation_data, $variation ){ woocommerce_wp_text_input( array( ‘id’ … Read more

How to display product cropped thumbnail (150×150) for WooCommerce product categories

To include the product category thumbnail (125 × 125 px) in your product category items (buttons), use the following: $product_cats = get_terms([ ‘taxonomy’ => ‘product_cat’, ‘hide_empty’ => true, ‘parent’ => 0, ]); foreach ( $product_cats as $key => $parent_term ) { $thumb_id = get_woocommerce_term_meta( $parent_term->term_id, ‘thumbnail_id’, true ); $size=”thumbnail”; $image = wp_get_attachment_image_src($thumb_id, $size); printf( ‘<button … 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>’; } ?>

Customize WooCommerce orders displayed shipping

There are mainly 2 filters to be used: 1) the filter woocommerce_order_shipping_to_display located in get_shipping_to_display() method, used by get_order_item_totals() method to display the shipping in order total rows: add_filter( ‘woocommerce_order_shipping_to_display’, ‘customize_order_shipping_to_display’, 10, 3 ); function customize_order_shipping_to_display( $shipping, $order, $tax_display ){ // Your code to filter displayed shipping return $shipping; } 2) Or filter woocommerce_get_order_item_totals located … Read more