:::: MENU ::::
Monthly Archives: July 2021

WooCommerce get comments by user id

Today we talk about WooCommerce or WordPress get comments by user id programmatically. In this tutorial, We focus on how to get user comments by using user id.

Let’s start with our example.

 $commentArg = array(
    'user_id' => 25,
         
    );
$comments = get_comments( $commentArg );
    if($comments){
      foreach($comments as $commentData){
        print_r($commentData);   
            }
                }
Author: Qaisar Satti
Last Modified: July 14, 2021


WooCommerce get comments by a user email

Today we talk about WooCommerce or WordPress get comments by a user email programmatically. In this tutorial, We focus on how to get user comments by using user email.

Let’s start with our example.

 $commentArg = array(
    'author_email' => $email,
         
    );
$comments = get_comments( $commentArg );
    if($comments){
      foreach($comments as $commentData){
        print_r($commentData);   
            }
                }
Author: Qaisar Satti
Last Modified: July 14, 2021


WooCommerce get an order by user id

Today we talk about WooCommerce or WordPress get an order by user id programmatically. In this tutorial, We focus on how to get user orders by using user id.

Let’s start with our example.

 $orderArg = array(
    'customer_id' => 23,
    'limit' => -1,
    'orderby' => 'date',
        'order' => 'DESC',
    );
$orders = wc_get_orders($orderArg);
if($orders){
  foreach ($orders as  $orderData) {
                print_r($orderData);
         }
}
Author: Qaisar Satti
Last Modified: July 14, 2021


WooCommerce get order by user email

Today we talk about WooCommerce or WordPress get an order by user email programmatically. In this tutorial, We focus on how to get user orders by using the user email.

Let’s start with our example.

 $orderArg = array(
    'customer' => $email,
    'limit' => -1,
    );
$orders = wc_get_orders($orderArg);
if($orders){
  foreach ($orders as  $orderData) {
                print_r($orderData);
         }
}
Author: Qaisar Satti
Last Modified: July 14, 2021


WooCommerce hide add to cart on shop page

Today we talk about WooCommerce or WordPress hide or remove add to cart on shop page programmatically. In this tutorial, We focus on how to hide/remove add to cart on the shop page.

Let’s start with our example.

add_action( 'woocommerce_after_shop_loop_item', 'qaisar_satti_remove_addtocart', 1 );

function qaisar_satti_remove_addtocart() {
  remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
}

If you want check with only the category listing page and shop page. You can use the following check.

     if( is_product_category() || is_shop()) {
      remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
     }
Author: Qaisar Satti
Last Modified: July 14, 2021


WooCommerce Select Variations on Shop Page

Today we talk about WooCommerce or WordPress select variation on shop page programmatically. In this tutorial, We focus on how to show select/dropdown on the shop page. It will be easier for customers to add to the cart with variations from the shop page. It will eliminate the step of the go-to single page and add to the cart from there.

Let’s start with our example.

   add_action('woocommerce_before_shop_loop', 'qaisar_satti_variations_dropdown');

function qaisar_satti_variations_dropdown() {
  remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); // remove already add to cart
  add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_single_add_to_cart', 50 );// add sigle page add to cart
}
Author: Qaisar Satti
Last Modified: July 14, 2021