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

Woocommerce SKU on ALL products page [closed]

Hope this code will helpful for you, the sku will be displayed at the end of shop loop function shop_display_skus() { global $product; if ( $product->get_sku() ) { echo ‘<div class=”product-meta”>SKU: ‘ . $product->get_sku() . ‘</div>’; } } add_action( ‘woocommerce_after_shop_loop_item’, ‘shop_display_skus’, 9 );

woocommerce change order statuses count for specific role

Normally pre_get_post doesn’t change wordpress views post count. You have to call another filter hook to change to count. add_action(‘pre_get_posts’, function ($query) { global $pagenow; if (isset($query->query_vars[‘post_type’])) { if ($query->query_vars[‘post_type’] == ‘shop_order’ && (‘edit.php’ == $pagenow)) { if (!$query->is_main_query()) { return; } // I manipulate $query here // Get Post Count Here For Each Status … Read more

Create WooCommerce new order with specific ID

Well.. You can add meta for original and cloned order. Just add +1 for it, each time when you will clone items. function create_order( $original_order_id, … try { $new_order = new WC_Order(); $new_order->set_props( array( … } $original_order = wc_get_order( $original_order_id ); $order_item_num = $original_order->get_meta(‘_order_items_num’); if($order_item_num >= 1) { $new_order->update_meta_data( ‘_order_item_num’, $order_item_num+1 ); $new_order->save(); $original_order->update_meta_data( ‘_order_items_num’, … Read more

Woocommerce Product Image and Thumbnails custom function

In short: We are going to overwrite the default template and change the function that is being called to generate our tag and the image inside it. Next, we are going to create this function into our functions.php and add the attribute we want to the tag. copy/paste the template woocommerce/templates/single-product/product-image.php to your directory: your-child-theme/woocommerce/single-product/product-image.php … Read more

Target WooCommerce Product Gallery Image (rather than Featured Image) for og:image

You will need to use the methods on one of the WooCommerce product object for example: function insert_fb_in_head() { global $post; if ( !is_singular()) //if it is not a post or a page return; echo ‘<meta property=”og:title” content=”‘ . get_the_title() . ‘”/>’; echo ‘<meta property=”og:type” content=”article”/>’; echo ‘<meta property=”og:url” content=”‘ . get_permalink() . ‘”/>’; echo … Read more

paypal not showing on woocommerce payments

Paypal standard is now hidden for new installs, possible to read about it in https://developer.woocommerce.com/2021/07/12/developer-advisory-paypal-standard-will-be-hidden-on-new-installs/ for those who want to use it copy paste this code on functions.php add_filter( ‘woocommerce_should_load_paypal_standard’, ‘__return_true’ ); Since july 2021 woocommerce recommends users to use the recommended PayPal extension instead

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)