Create or Update thousands of woocommerce products via PHP
Create or Update thousands of woocommerce products via PHP
Create or Update thousands of woocommerce products via PHP
I would try to rename the custom function and add meta_query too! So it’d be like this: function my_shop_custom_products_query( $q ) { $q->set( ‘meta_key’, ‘_thumbnail_id’ ); $q->set(‘orderby’, ‘meta_value_num’); $q->set(‘order’, ‘DESC’); $q->set( ‘meta_query’, array( array( ‘key’ => ‘_thumbnail_id’, ‘compare’ => ‘>=’, ‘value’ => ‘0’ ))); } add_action( ‘woocommerce_product_query’, ‘my_shop_custom_products_query’ ); If for some reason it didn’t … Read more
Figured it out where I had if ( ! empty( $cart_item[‘presc_data’] ) ) woocommerce_add_order_item_meta( $item_id, ‘Olho Direito’, $cart_item[‘presc_right_sphere’] ); I had to change to $data = $cart_item[‘presc_data’]; if ( ! empty( $cart_item[‘presc_data’] ) ) woocommerce_add_order_item_meta( $item_id, ‘Olho Direito’, $data[‘presc_right_sphere’] );
The outdated files are in your theme’s woocommerce folder (unless the theme has stored them elsewhere, but that is the default). You don’t need this folder per se and can rename it (which is the more temporary way than flat-out deleting it) and WooCommerce will work. If you purchased the theme you could also contact … Read more
The only required template in a WordPress theme is the index.php. And a comments.php if comments are supported. Following the template hierarchy, all other files, including page.php, will fall back to the index.php. When a theme doesn’t have a page.php, look at the index.php. There you will find the basic structure for its content. In … Read more
Before I begin, just one note, there is no property called $all in get_the_terms. Here are the available fields which you can use stdClass Object ( [term_id] => [name] => [slug] => [term_group] => [term_order] => [term_taxonomy_id] => [taxonomy] => Get only one product category woocommerce => [parent] => [count] => [object_id] => ) I’m … Read more
I would reverse engineer the User Switching plugin and then create a solution that works for you. Fortunately there is not a whole lot of work to do. Most of the crucial functionality is in this function: function switch_to_user( $user_id, $remember = false, $set_old_user = true ) { if ( ! $user = get_userdata( $user_id … Read more
get_terms() accept an array of arguments as second parameter. One of those parameters are include include (integer) An array of term ids to include. Empty returns all. You already have your selected term ids in an array, so just simply pass them to the include parameter in the array of arguments in get_terms() $terms = … Read more
May be you have just enabled the ‘Enable shipping’ from shipping options page(Woocommerce -> Settings -> Shipping ). You need to enable the Shipping Methods also. For enabling shipping methods click on shipping method name from shipping methods table displayed on shipping options page. Check the checkbox ‘ Enable this shipping method ‘ and save … Read more
storefront_single_post hook pertains only to single posts and not products although products are considered posts of type ‘product’ This is the hook you need: add_action( ‘woocommerce_single_product_summary’, ‘storefront_post_header_categories’, 6 ); function storefront_post_header_categories() { echo “code to display categories here”; } You will find it in plugins/woocommerce/content-single-product.php: /** * woocommerce_single_product_summary hook * * @hooked woocommerce_template_single_title – 5 … Read more