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 pleaseIf 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.
Quote from Polka on January 14, 2023, 00:23Hi. I am writing a function that I want to only execute on the filtered results pages (and on the main
storepage 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
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
Quote from Pablo Borysenco on January 16, 2023, 13:38hello
this code will determine if there is a search query
global $WOOCS;
if ($WOOCS->is_isset_in_request_data($WOOCS->get_swoof_search_slug())) {
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())) {
Quote from Polka on January 16, 2023, 17:18Thank 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?
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?Quote from Pablo Borysenco on January 17, 2023, 11:32Hello
Oh! Sorry! I messed up $WOOCS and $WOOF
Try it:
global $WOOF;
if ($WOOF->is_isset_in_request_data($WOOF->get_swoof_search_slug())) {
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())) {
Quote from Polka on January 17, 2023, 20:08I 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; } }
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;
}
}Quote from Pablo Borysenco on January 18, 2023, 14:18Hello
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!"; }
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!";
}
Quote from Polka on January 18, 2023, 14:22Yes, 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.
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.
Quote from Pablo Borysenco on January 19, 2023, 12:34Hello
Ok! Try to use
if (isset($_GET['swoof'])) {
Hello
Ok! Try to use
if (isset($_GET['swoof'])) {
Quote from Polka on January 20, 2023, 17:09Nope. 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
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
Quote from Pablo Borysenco on January 23, 2023, 13:13Hello
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
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
Quote from Polka on January 23, 2023, 21:55Hmm, that might be a possibility. I don't really know much about ajax.
Thanks again for trying to help!
Hmm, that might be a possibility. I don't really know much about ajax.
Thanks again for trying to help!