PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Function to detect when on a HUSKY page

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi. I am writing a function that I want to only execute on the filtered results pages (and on the main store page previous to a filter being enabled). Is there a function that I can use to determine whether I'm on a HUSKY page?

I've tried the usual WooCommerce is_page , etc. but those functions aren't working.

Is there a function or a constant variable I can check?

I'm trying to change the way the product names display. Here's the code I want to use:

add_filter( 'woocommerce_product_variation_title', 'lrc_variation_with_attribute', 10, 4 );
function lrc_variation_with_attribute( $variation_title, $product, $title_base, $title_suffix ) {
if ( I AM ON A HUSKY PAGE) {
$attribute = wc_get_formatted_variation( $product->get_variation_attributes(), true );
$product_parent = wc_get_product( $product->get_parent_id() );
$product_title = $product_parent->get_name();
return $product_title ."<br><small>" . $attribute ."</small>";
} else {
return $variation_title;
}
}

I need something to replace `I AM ON A HUSKY PAGE`.

Thanks in advance

hello

this code will determine if there is a search query

global $WOOCS;

if ($WOOCS->is_isset_in_request_data($WOOCS->get_swoof_search_slug())) {

Thank you! I tried this, but there must be an error somewhere because it results in a blank page:

 

add_filter( 'woocommerce_product_variation_title', 'lrc_variation_with_attribute', 10, 4 );
function lrc_variation_with_attribute( $variation_title, $product, $title_base, $title_suffix ) {
global $WOOCS;
if ($WOOCS->is_isset_in_request_data($WOOCS->get_swoof_search_slug())) {
$attribute = wc_get_formatted_variation( $product->get_variation_attributes(), true );
$product_parent = wc_get_product( $product->get_parent_id() );
$product_title = $product_parent->get_name();
return $product_title ."<br><small>" . $attribute ."</small>";
} else {
return $variation_title;
}
}


Any idea what I can try?

Hello

Oh!  Sorry! I messed up  $WOOCS and $WOOF

Try  it:

global $WOOF;

if ($WOOF->is_isset_in_request_data($WOOF->get_swoof_search_slug())) {

I tried that and it doesn't crash this time (thanks :-) ) but it also doesn't resolve to True when I visit a page that is clearly being filtered. Like this one: https://www.lisaclarke.net/store/?swoof=1&stock=instock It still returns the original variation name instead of executing the code to display attributes. Any other ideas?

 

add_filter( 'woocommerce_product_variation_title', 'lrc_variation_with_attribute', 10, 4 );
function lrc_variation_with_attribute( $variation_title, $product, $title_base, $title_suffix ) {
global $WOOF;
if ($WOOF->is_isset_in_request_data($WOOF->get_swoof_search_slug())) {
$attribute = wc_get_formatted_variation( $product->get_variation_attributes(), true );
$product_parent = wc_get_product( $product->get_parent_id() );
$product_title = $product_parent->get_name();
return $product_title ."<br><small>" . $attribute ."</small>";
} else {
return $variation_title;
}
}

Hello

Are you sure that this hook changes titles where you need it?

Try  a  test:

add_filter( 'woocommerce_product_variation_title', 'lrc_variation_with_attribute', 10, 4 );
function lrc_variation_with_attribute( $variation_title, $product, $title_base, $title_suffix ) {
return"title test!";
}

 

Yes, I'm sure it does. I've used it successfully without the if statement. I'm just hoping to narrow it down so it only works on the husky pages.

Hello

Ok!  Try  to  use

if (isset($_GET['swoof'])) {

Nope. Still doesn't work. I really don't get it. I've tried all kinds of conditions in this thing, and none of them work. It only does what I want when I remove the conditions completely.

I mean, I would be happy just to say"do it on any page except the cart" but if ( !is_cart() ) { doesn't even work. It's baffling. Trying to detect when I'm on a HUSKY page was my last resort.

I appreciate your help so far, and if you have more ideas I'd love to hear them. But if not, it's ok. I know you've tried!

Thanks,

Lisa

Hello

Very strange.  This condition must work with this global variable

One of the options (why it doesn't work) - This function with this hook works in ajax request. i mean a request where there is no page object and another url

Hmm, that might be a possibility. I don't really know much about ajax.

Thanks again for trying to help!

Welcome;)