Function to Set Product type in Woocommerce [closed]
I figured this out, to set the product_type, instead of using update_post_meta(), you use: wp_set_object_terms( $productID, ‘subscription’, ‘product_type’ );
I figured this out, to set the product_type, instead of using update_post_meta(), you use: wp_set_object_terms( $productID, ‘subscription’, ‘product_type’ );
Okay, based on answers on link above (where I got the old code and there are people that help to answered), I put the modification code for my website. I tried it and it’s working like charm. Change: add_action( ‘woocommerce_product_after_variable_attributes’, ‘variable_fields’, 10, 2 ); Into : add_action( ‘woocommerce_variation_options’, ‘variable_fields’, 10, 3 ); And change : … Read more
I’m not sure what the job_listing post type refers to – it’s probably part of a feature included in your theme – but in order to limit your search results by post type, the usual way to do this is by hooking into WordPress’ pre_get_posts action in your theme’s functions.php. Because you’re new to this, … Read more
There are two ways you could do that. 1. Using JS only WordPress themes normally use the body_class() function. As a result you’ll see that the <body> tag will have lots of classes. You can then target pages with a specific class to run your code in JavaScript: if( $(‘body.whateverclass’).length || $(‘body.anotherclass’).length ){ // Your … Read more
To process payment for an WooCommerce Order, the workflow goes like the following: Create an WooCommerce Order Process Payment for this order, using one of WC_Payment_Gateways Change order status (default is pending->processing, or to complete if empty order) IMHO, Step two can be implemented as the following: Use a front-end lib to tokenize payment info, … Read more
I hope think this may work. Insert this code into php file or php insert plugin, WooCommerce will no longer change password reset link. function reset_pass_url() { $siteURL = get_option(‘siteurl’); return “{$siteURL}/wp-login.php?action=lostpassword”; } add_filter( ‘lostpassword_url’, ‘reset_pass_url’, 11, 0 );
Since WooCommerce 3.2, Woocommerce shortcodes and their available attributes have changed. So try the following shortcode instead (for “foo” product category): [product_category limit=”90″ columns=”3″ category=”foo” paginate=”true”] or inside php code: echo do_shortcode( ‘[product_category limit=”90″ columns=”3″ category=”foo” paginate=”true”]’ ); Now you will see that the sorting options dropdown appear. Note: orderby argument with an empty value … Read more
Instead of editing the template you could also try this: <?php /** Remove short description if product tabs are not displayed */ function dot_reorder_product_page() { if ( get_option(‘woocommerce_product_tabs’) == false ) { remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_excerpt’, 20 ); } } add_action( ‘woocommerce_before_main_content’, ‘dot_reorder_product_page’ ); /** Display product description the_content */ function dot_do_product_desc() { global $woocommerce, $post; … Read more
I couldn’t find this documented anywhere, but the solution is pretty simple. In single_product_review.php, the arguments passed to wp_list_comments are filtered: wp_list_comments( apply_filters( ‘woocommerce_product_review_list_args’, array( ‘callback’ => ‘woocommerce_comments’ ) ) ); by adding reverse_top_level to the arguments, the order is reversed. Add the following code to your theme’s functions.php: // show newest product reviews on … Read more
Palm to FACE!!! using the product id… $_product = get_product(id); $_product = wc_get_product() $shipclass = $_product->get_shipping_class(); this returns the products shipping class. EDIT: as mentioned by Aniruddha get_product is depreciated answer has been updated.