Custom Redirect after registration in WooCommerce

Internally, WooCommerce uses WordPress’ wp_safe_redirect() which does not allow redirects to external hosts. In order to get around this, we must add our desired host to the whitelist. The whitelist can be modified using the allowed_redirect_hosts which has been demonstrated below: /** * Adds example.com to the list of allowed hosts when redirecting using wp_safe_redirect() … Read more

Output link to category from WP_Query loop of woocommerce products

You can use get_the_term_list() to output a comma-separated list of links to product categories: <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <li class=”product-list__item”> <a href=”https://wordpress.stackexchange.com/questions/274473/<?php the_permalink() ?>”> <?php the_title(); ?> </a> <?php echo get_the_term_list( get_the_ID(), ‘product_cat’, ”, ‘, ‘ ); ?> </li> <?php endwhile; ?> Note that when you’re inside ‘the loop’ (i.e. between … Read more

How to exclude products by tag from woocommerce shop page?

Add this to your functions.php function custom_pre_get_posts_query( $q ) { $tax_query = (array) $q->get( ‘tax_query’ ); $tax_query[] = array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => array( ‘banana’ ), // Don’t display products with the tag “banana” ‘operator’ => ‘NOT IN’ ); $q->set( ‘tax_query’, $tax_query ); } add_action( ‘woocommerce_product_query’, ‘custom_pre_get_posts_query’ );

Get user payment details when payment successfully done in woocommerce [closed]

Yes, after an order created you can get details of it. The woocommerce_payment_complete hook is fired when the payment is completed. The only variable passed is the order id, though from that you can get the order object, and ultimately the user. add_action( ‘woocommerce_order_status_completed’, ‘so_payment_complete’ ); function so_payment_complete( $order_id ){ $order = wc_get_order( $order_id ); … Read more