Add the Name of Products Ordered to Admin New Order Email WooCommerce

Since Woocommerce 3 your actual code is a bit outdated. In the following you will get all products names (coma separated) in the email subject. add_filter(‘woocommerce_email_subject_new_order’, ‘change_admin_email_subject’, 10, 2); function change_admin_email_subject( $subject, $order ) { $products_names = array(); foreach ( $order->get_items() as $item ) { $products_names[] = $item->get_name(); } return sprintf( ‘[%s] New Customer Order … Read more

Save and display selected product option and cost as cart item data in WooCommerce

The following revisited code will change cart item subtotal to the calculated sum of product + color option and will reflect this change to cart totals. It will save the option as order item meta data, when order is placed. The code: // Display Select field before add to cart button add_action( ‘woocommerce_before_add_to_cart_button’, ‘colors_options_before_add_to_cart_button’ ); … Read more

How to get the WC_Product Object when using a WP_Query in WooCommerce

The global $product; doesn’t work in a custom WP_Query, instead use wc_get_product() like: if ($slider_products_q->have_posts()): while($slider_products_q->have_posts()): $slider_products_q->the_post(); $product_id = get_the_ID(); $product = wc_get_product($product_id); $price_html = $product->get_price_html() // … Now you can use any WC_Product methods on $product variable. Alternatively, you could use a WC_Product_query.

WooCommerce E-Check payment gateway disappeared when site switched to multi-site

It’s because of this: if ( in_array( ‘woocommerce/woocommerce.php’, apply_filters( ‘active_plugins’, get_option( ‘active_plugins’ ) ), true ) ) { self::$instance->setup_constants(); self::$instance->hooks(); self::$instance->includes(); self::$instance->load_textdomain(); add_filter( ‘woocommerce_payment_gateways’, array( self::$instance, ‘add_wc_gateway’ ) ); } The entire class doesn’t do anything if this condition isn’t true: in_array( ‘woocommerce/woocommerce.php’, apply_filters( ‘active_plugins’, get_option( ‘active_plugins’ ) ), true ) The problem is that … Read more

Woocommerce Product Price Inserted programmatically doesn’t get displayed In Single Product Page

Try the following using the WC_Product Object and methods instead: // Starting scrape $html = file_get_html(‘http://sitenam.com/page-1/’); $price = (float) $html->find(‘span[class=”price”]’, 0)->innertext; // Saving the new product $post_id = wp_insert_post( array( ‘post_author’ => 1, ‘post_content’ => ‘Content Here’, ‘post_status’ => “publish”, ‘post_title’ => “Product Title Here”, ‘post_parent’ => “product-title-here”, ‘post_type’ => “product”, ) ); // Setting … Read more