WooCommerce Filters – Astra https://wpastra.com Fast, Lightweight & Customizable WordPress Theme for Any Website Wed, 04 May 2022 12:40:33 +0000 en-US hourly 1 https://wordpress.org/?v=5.9.3 https://wpastra.com/wp-content/uploads/2020/01/favicon-astra2x.png WooCommerce Filters – Astra https://wpastra.com 32 32 Remove Woocommerce Product Category Archive Title https://wpastra.com/docs/remove-woocommerce-category-archive-title/ https://wpastra.com/docs/remove-woocommerce-category-archive-title/#respond Fri, 21 Jan 2022 16:39:21 +0000 https://wpastra.com/?post_type=docs&p=116553 Remove Woocommerce Product Category Archive Title Read More »

]]>
When you click on the category of your WooCommerce product, you will be transferred to the archive page. The category archive page will contain all products that belong to this category. If you want to remove the category archive title on the page, this document will help you do it.

Remove the WooCommerce category archive title

How To Remove This?

To remove the category archive title, you must add a filter. You can add the following custom code to the functions.php file of your Child Theme:

# Remove Woocommerce Category Title from the product archive page

add_filter( 'woocommerce_show_page_title', 'remove_category_title_from_product_archive' );
function remove_category_title_from_product_archive( $title ) {
if ( is_product_category() ) {
$title = false;
}
return $title;
}

If you don’t have your Child Theme installed, please check this article on how to do it. 

If you are not sure how to add this code, please check this article.

]]>
https://wpastra.com/docs/remove-woocommerce-category-archive-title/feed/ 0
Remove Astra Customization for WooCommerce https://wpastra.com/docs/remove-astra-customization-for-woocommerce/ https://wpastra.com/docs/remove-astra-customization-for-woocommerce/#respond Wed, 19 Jan 2022 15:57:54 +0000 https://wpastra.com/?post_type=docs&p=116477 Remove Astra Customization for WooCommerce Read More »

]]>
The Astra Theme comes with out-of-the-box customization options for the WooCommerce plugin. You can use these to customize the Shop, Cart, and Checkout Pages as well as Single Products. 

Contrary, to use the default WooCommerce pages and options for your website, you need to use custom code. Thus, you can learn how to do it with this document.

What Will be the Result?

Astra theme and Astra Pro addon both allow you to customize WooCommerce pages according to your needs and brand. 

WooCommerce Customizing

Further, these customization options are applied automatically to your online store as soon as you install Astra. At the same time, this will add additional Astra-related code. Also, you will notice additional settings in the customizer too. 

Now, adding the code from this document will revert your WooCommerce pages, code, and customizer to defaults. For example, you might need this for some 3rd-party plugins to work well or make your own customizations.

WooCommerce Removed Astra Options

How To Change This?

To remove Astra customization and revert WooCommerce to defaults, you’ll need to add a filter. You can add the following custom code to the functions.php file of your Child Theme:

add_filter( 'astra_enable_woocommerce_integration', '__return_false' );

If you don’t have your Child Theme installed, please check this article on how to do it. 
If you are not sure how to add this code, please check this article.

]]>
https://wpastra.com/docs/remove-astra-customization-for-woocommerce/feed/ 0
How To Hide Quantity Number When the Woocommerce Cart Is Empty? https://wpastra.com/docs/hide-quantity-when-cart-is-empty/ https://wpastra.com/docs/hide-quantity-when-cart-is-empty/#respond Mon, 06 Sep 2021 14:41:45 +0000 https://wpastra.com/?post_type=docs&p=103256 How To Hide Quantity Number When the Woocommerce Cart Is Empty? Read More »

]]>
Astra’s Header Footer Builder comes with the WooCommerce Cart element that allows you to add the mini-cart to your header. By default, the mini-cart displays a number of items added to the cart together with the icon.

The mini-cart will show the number “0” until the first product is added to the cart. 

WooCommerce Mini-Cart

In case you would like to hide this number, you can do it by adding a custom code (filter). Adding the filter will hide the number of products while the mini-cart is empty.

Filter to Hide the Quantity Number When Cart I Empty

To do this, you would need to add the following filter to the functions.php file of your Child Theme:

add_filter('astra_woo_header_cart_total', 'remove_cart_count');
function remove_cart_count( $default){
	if(0 == WC()->cart->get_cart_contents_count()){
		return false;
	}else{
		return $default;
	}
}

If you don’t have your Child Theme installed, please check this article on how to do it.

If you are not sure how to add this code, please check this article

]]>
https://wpastra.com/docs/hide-quantity-when-cart-is-empty/feed/ 0
Restrict Search Results to WooCommerce Products Only https://wpastra.com/docs/restrict-search-results-products/ https://wpastra.com/docs/restrict-search-results-products/#respond Wed, 04 Aug 2021 19:13:55 +0000 https://wpastra.com/?post_type=docs&p=101457 Restrict Search Results to WooCommerce Products Only Read More »

]]>
By default, when visitors use the Search option on your website, the results will show posts, pages, products, etc. that fit the term searched.

If you’re running an online store, you might want to limit the search only to WooCommerce products. This can help users find products faster and increase the conversion rate on your website.

To do this, you would need to add the following filter to the functions.php file of your Child Theme:

add_filter( 'get_search_form', 'astra_get_search_form_callback' );
function astra_get_search_form_callback( $search_form ) {
	$search_form = str_replace( '-1">', '-1"/><input type="hidden" name="post_type" value="product"/>', $search_form ); 
	return $search_form;
}

If you don’t have your Child Theme installed, please check this article on how to do it.

If you are not sure how to add this code, please check this article.

]]>
https://wpastra.com/docs/restrict-search-results-products/feed/ 0
Fix Woocommerce Cart Becoming Transparent With Header Builder https://wpastra.com/docs/fix-transparent-woocommerce-cart/ https://wpastra.com/docs/fix-transparent-woocommerce-cart/#respond Tue, 27 Jul 2021 12:06:25 +0000 https://wpastra.com/?post_type=docs&p=101100 Fix Woocommerce Cart Becoming Transparent With Header Builder Read More »

]]>
If you decided to switch from the old Astra header to a new Header Footer Builder, you might have noticed that your WooCommerce mini cart became transparent. 

Astra Theme version 3.6.7 came with the fix for this, but the fix is not applied automatically to existing websites. Learn how to apply it to your website.

Why Do I Need This Improvement?

The WooCommerce cart added to your old Astra header had the background set to white color by default. 

Old Astra Header - WooCommerce Cart

Switching to Astra’s Header Footer Builder caused the cart to become transparent.

Fix WooCommerce Cart Becoming Transparent with Header Builder

Though Astra 3.6.7 update comes with the fix, this won’t be applied automatically to your website to avoid unwanted effects on your existing websites.

How To Fix This?

For all new websites, this fix will be applied automatically when the theme is updated. 

As mentioned, for the existing website, this fix needs to be activated by adding a filter. This was done to allow you to check how these changes apply to your website and make any changes if needed. 

To apply the improvement to your existing website, you would need to add a filter to the functions.php file of your Child Theme. If you don’t have your Child Theme installed, please check this article on how to do it. Please add the following filter:

add_filter( 'astra_apply_background_to_outline_cart_builder_element', '__return_true' );

If you are not sure how to add this code, please check this article.

]]>
https://wpastra.com/docs/fix-transparent-woocommerce-cart/feed/ 0
Change the “Shopping Cart” Text for WooCommerce & EDD Mobile Header Cart https://wpastra.com/docs/update-mobile-cart-title/ Fri, 28 May 2021 11:46:02 +0000 https://wpastra.com/?post_type=docs&p=91559 Change the “Shopping Cart” Text for WooCommerce & EDD Mobile Header Cart Read More »

]]>
If you have the WooCommerce or EDD cart added to your websites’ mobile header, you might want to modify the cart title. Since Astra Theme version 3.5.0, this can easily be done.

WooCommerce & EDD Mobile Header Cart, Astra 3.5.0

With Astra Theme versions 3.5.0 and above you can change the default “Shopping Cart” text to anything you need to. 

Chnage the WooCommerce & EDD Cart Title, Astra 3.5.0

To do this, you would need to add a filter to the functions.php file in your Astra Child Theme. Please add the following code:

add_filter( 'astra_header_cart_flyout_shopping_cart_text', function() {
return 'My Shop Flyout Cart';
} );

You can change the title to any text you want – just modify My Shop Flyout Cart text in the code above.

Note:

For additional details on how to add a custom code to the functions.php file please see this article: How to Add Custom PHP Code?

]]>
Filter to Add Global Button Settings Support for WooCommerce Buttons https://wpastra.com/docs/global-button-support-for-woocommerce-buttons/ Tue, 28 Jul 2020 03:48:24 +0000 https://wpastra.com/?post_type=docs&p=63056 Filter to Add Global Button Settings Support for WooCommerce Buttons Read More »

]]>
Are you looking to add Global Button Settings Support for the WooCommerce Buttons? Now with the Astra Theme version 2.5.0, will be resolved –

For New Users:

On your fresh or new installations, compatibility of Global Button Settings will be provided for the WooCommerce Buttons by default.

For Existing Users:

You can use the following filter in the child theme’s functions.php to provide Global Button’s Support for the WooCommerce buttons.

add_filter( 'astra_global_btn_woo_comp' , '__return_true' );

Note

Refer this doc on How to Add Custom PHP Code?

]]>
How to Modify/Change the Quick View text? https://wpastra.com/docs/modify-quick-view-text/ Tue, 21 Jul 2020 12:28:18 +0000 https://wpastra.com/?post_type=docs&p=63041 How to Modify/Change the Quick View text? Read More »

]]>
As a shop owner, you might want to change the Quick View text. In this article, we will be seeing how to change the Quick View text using a filter.

In our WooCommerce Addon, as you can see we have the option to display the Quick View text based on the position which you have selected from the Astra settings.

So below are the filter based on the position to change the Quick View text –

1] For “On Image” position, you can use the following filter –

/**
 * Change Quick View text from the shop page (for on image button option)
 *
 */

add_filter( 'astra_woo_add_quick_view_text_html', 'astra_woo_add_quick_view_text_html_func', 10, 3 );

function astra_woo_add_quick_view_text_html_func( $button, $label, $product_id ) {

    global $product;
    $product_id = $product->get_id();

    $label = __( 'Buy Now', 'astra-addon' );
    $button = '<a href="#" class="ast-quick-view-text" data-product_id="' . esc_attr( $product_id ) . '">' . $label . '</a>';
    
    return $button;
}

Here’s how it would display Before and After using the above filter –

Before –

Astra Pro - WooCommerce, On Image Quick View text - Before, Astra 3.0+

After –

Astra Pro - WooCommerce, On Image Quick View text - After, Astra 3.0+

2] For After Summary position, you can use the following filter –

/**
 * Change Quick View text from the shop page (for after summary option)
 *
 */

add_filter( 'astra_woo_add_quick_view_button_html', 'astra_woo_add_quick_view_button_html_func', 10, 3 );

function astra_woo_add_quick_view_button_html_func( $button, $label, $product_id ) {

    global $product;
    $product_id = $product->get_id();

    $label = __( 'Buy Now', 'astra-addon' );
    $button = '<div class="ast-qv-button-wrap">';
    $button .= '<a href="#" class="button ast-quick-view-button" data-product_id="' . esc_attr( $product_id ) . '">' . $label . '</a>';
    $button .= '</div>';
    
    return $button;
}

Here’s how it would display Before and After using the above filter.

Before 

Astra Pro - WooCommerce, After Summary Quick View text - Before, Astra 3.0+

After –

Astra Pro - WooCommerce, After Summary Quick View text - After, Astra 3.0+

Note:

1. The above filter will change the “Quick View” text to the “Buy Now” text. You can update it as per your requirement.

2. Paste the above code in the child theme’s functions.php file.

]]>
How to Disable Product Quantity (Plus-Minus) Buttons? https://wpastra.com/docs/disable-plus-minus-buttons/ Wed, 06 Nov 2019 11:39:13 +0000 https://wpastra.com/?post_type=docs&p=46309 How to Disable Product Quantity (Plus-Minus) Buttons? Read More »

]]>
In Astra Pro Addon’s version 2.1.0, we have improved the Product Quantity input’s old number field and replaced it with the Plus-Minus buttons.

For which we have provided a Filter that will disable the Product Quantity’s Plus-Minus buttons. This will be for the Product Quantity field on the WooCommerce Cart and Single Product Page.

This change could now be seen for the Product Quantity Input field on WooCommerce Cart and Single Product Page.

Product Quantity old buttons before Astra 2.1.0

Some users, still require to have the below number field for the product quantity. Here’s a screenshot of the old quantity field –

Astra New Product Quantity Buttons Old

To achieve this requirement, we are providing a filter in our Astra Pro Addon’s plugin version 2.1.3. Make sure you update the plugin to version 2.1.3 or above to use the filter.

add_filter( 'astra_add_to_cart_quantity_btn_enabled', '__return_false' ); 

Description: This filter is built to replace the product quantity’s new plus-minus field to the old number field.

You will need to add this filter, in the child theme’s last line of functions.php.

Note: Since this functionality is JavaScript based, in some cases this functionality might not work with the third-party plugins, and in such cases, users can also use the above filter.

Using the Code with Astra Pro

If you also have Astra Pro (Addon) Plugin installed and active, you might need additional steps. To make the changes visible on the front end, you will need to clear the Astra Cache. Please follow these steps:

Step 1 – Add a filter code functions.php file of your Astra Child Theme;

Step 2 – Navigate to Appearance > Astra Options and scroll down to the “Available Astra Pro Modules” section

Step 3 – Click the “Deactivate All” button, and then click the “Activate All” button (you can disable modules you don’t need afterward).

Step 4 – Check the front end of your website. If you still don’t see the change, please clear your browser cache by doing the hard refresh using Ctrl + Shift + R (Windows) / ⌘ Cmd + Shift + R (Mac).

]]>
Change Woocommerce Out of Stock Text https://wpastra.com/docs/change-woocommerce-out-of-stock-text/ Sun, 04 Nov 2018 18:30:00 +0000 https://wpastra.com/?post_type=docs&p=29517 Change Woocommerce Out of Stock Text Read More »

]]>
Astra adds a text “Out Of Stock” for the WooCommerece products that have ‘Stock status’ as out of stock. Below is the screenshot of how the text displays in the front end on the product –

Out of Stock WooCommerce

You can change the “Out Of Stock” text with any custom text you want, on both the Product Catalog (Shop page) and Single Product pages using filters.

You need to add the following filters to the functions.php file of your Child Theme:

  • Add the folowing code to change the “Out Of Stock” text on the Product Catalog (Shop page):
add_filter( 'astra_woo_shop_out_of_stock_string', 'out_of_stock_callback' );
function out_of_stock_callback( $title ) {
return 'SOLD';
}
  • Add the folowing code to change the “Out Of Stock” text on the Single Product pages:
add_filter( 'woocommerce_get_availability', 'change_out_of_stock_text_woocommerce', 1, 2 );
function change_out_of_stock_text_woocommerce( $availability, $product_to_check ) {
// Change Out of Stock Text
if ( ! $product_to_check->is_in_stock() ) {
    $availability['availability'] = __('SOLD', 'woocommerce');
}
return $availability;
}

Both of these codes will replace the “Out Of Stock” text with “SOLD”. You can modify this by replacing the bolded word “SOLD” in both codes with your custom text.

If you don’t have your Child Theme installed, please check this article on how to do it. 
If you are not sure how to add this code, please check this article.

]]>