Extend Woocommerce rest api routes fails

What if in your register_rest_route() call you can pass it the permission_callback option: ‘permission_callback’ => function () { return current_user_can(‘customer’); // OR return current_user_can(‘shop_manager’); } That way you are sure that you are dealing with a logged in Woocommerce user?? These are the two roles that Woocommerce is adding to your site. https://docs.woocommerce.com/document/roles-capabilities/ I know … Read more

Display WooCommerce size product attribute on shop page

Your code is outdated since WooCommerce 3. First, you need to target variable products type only to avoid errors on other products types and also $product is already the product object. Also you can also directly use the WC_Product method get_attribute() and your code will be much more simpler, compact and efficient: add_action( ‘woocommerce_after_shop_loop_item_title’, ‘display_size_attribute’, … Read more

Adding existing user custom field value to a woocommerce product [closed]

You can do this with an action when a new product is inserted (and not when updated). As you did not specify the meta key this field is stored under the user as, OR the meta key of where you want it stored on the product: add_action( ‘wp_insert_post’, ‘smyles_insert_user_product_data’, 10, 3 ); function smyles_insert_user_product_data( $post_ID, … Read more

How to Acheive the custom woocommerce category template

Lets see if this is helpfull. From your description you have/want the following setup: -Category –Sub-Category-1 —Products of Sub-Category-1 –Sub-Category-2 —Products of Sub-Category-2 –Sub-Category-3 —Products of Sub-Category-3 OK, so you first need to get all top level categories. You can get them with something like this: $top_categories_args = array( ‘taxonomy’ => ‘product_cat’, // the taxonomy … Read more

Get WooCommerce Email Classes in Backend

Like I’ve pointed in my comment, you can use wc()->mailer()->emails, which would give you a list of all the email class instances. Example: // Get all the email class instances. $emails = wc()->mailer()->emails; // Prints all the email class names. var_dump( array_keys( $emails ) ); // Access the default subject for new order email notifications. … Read more