WooCommerce Registration redirect based on page ID

The woocommerce_registration_redirect is a filter hook, but NOT an action hook. I’ve tried the shortcode provided in the mentioned link in your comment above and it works for me in this way: function AS_redirection_after_registration($redirection_url) { if($redirection_url ==”first-page-slug”) // $redirection_url is the slug of the current page where the shortcode is placed return home_url(‘/my-page’); elseif($redirection_url==”second-page-slug”) return … Read more

List just subcategory and products of active category page in Woocommerce

The code below works for me in archive-product.php not sure if it may also work in taxonomy-product_cat.php EDIT I’ve added some lines of code to exclude posts previously outputted, since a post can belong to several categories and that’s why you can find always the same posts if(is_a(get_queried_object(),’WP_term’)){ $subs=get_terms(‘product_cat’,array(‘parent’=>get_queried_object()->term_id)); //var_dump($subs); $to_excude=[]; foreach($subs as $sub){ $args … Read more

Can we use a library under MIT license in a WooCommerce plugin?

Disclaimer: I’m not a lawyer, so this isn’t legal advice. Yes, you can include MIT licensed code in something you sell. The MIT license is very permissive. From the license: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in … Read more

WooCommerce which roles and capabilities control user login re-direct to Woo Account Page?

WooCommerce will only show the admin bar and give dashboard access to users who have the edit_posts or manage_woocommerce capabilities. If you don’t want to give users one of those capabilities, you can use the woocommerce_disable_admin_bar filter to give access and show the admin bar: add_filter( ‘woocommerce_disable_admin_bar’, function( $disable_admin_bar ) { if ( current_user_can( ‘my_capability’ … Read more

Seo Friendly Filter URLs

Yes, it is possible. Option 1: Programmatically using add_rewrite_rule() Add the rewrite rule: /* The rule matches: * example.com/product-category/rings/rings-in-gold/ * example.com/product-category/rings/rings-in-gold/page/<number>/ */ add_action( ‘init’, function () { add_rewrite_rule( ‘^product-category/rings/rings-in-gold(?:/page/(\d+)|)/?$’, // $matches[1] is the (\d+) (page number) from the above Regex, if any. ‘index.php?product_cat=rings&filter_material=gold&paged=$matches[1]’, ‘top’ ); } ); For other categories, just copy the above add_rewrite_rule() … Read more

Set both meta_query and tax_query using wp_query->set

Just use another set() method: if ($value[‘pRange’] && $value[‘tags’]) { $wp_query->set(‘tax_query’, array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => $value[‘tags’], ), array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => $value[‘tags’], ), array( ‘taxonomy’ => ‘pa_branding’, ‘field’ => ‘slug’, ‘terms’ => $value[‘tags’], ), ) ); $wp_query->set(‘meta_query’, array( ‘relation’ => ‘AND’, … Read more

Add Name and SKU Main Product to Secondary Product to Cart

I would therefore create a new short code based on the existing one https://docs.woocommerce.com/wc-apidocs/source-class-WC_Shortcodes.html#295 Where before adding the product (sample) to the shopping cart the values ​​of the sample product will be updated with the values ​​of the (main) product. then you could using something like this $product = wc_get_product( $product_id ); $product->set_sku( 1234 ); … Read more