Apply jquery script to only woocommerce product pages and categories

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

Process checkout using WC REST API

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

Display sorting options dropdown when using WooCommerce product category shortcode

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

Changing Woocommerce Product Description [closed]

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

Display WooCommerce newest product reviews on top [closed]

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

Create WooCommerce Product Category Programmatically

To create a taxonomy term programmatically you can use wp_insert_term function. <?php wp_insert_term( $term, $taxonomy, $args = array() ); ?> It has 3 params: $term (int|string) (required) The term to add or update. Default: None $taxonomy (string) (required) The taxonomy to which to add the term. Default: None $args (array|string) (optional) Change the values of … Read more

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