Search
 
SCRIPT & CODE EXAMPLE
 

PHP

remove add to cart woocommerce button

function chiefthemes_remove_addcart() {
   $product = get_product();
   if ( has_term ( 'category-name', 'product_cat') ) {
       remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
       remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
       remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
       remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
       remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
       remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
   }
}
add_action( 'wp', 'chiefthemes_remove_addcart' );
Comment

Add Empty Cart Button WooCommerce

add_action( 'woocommerce_cart_coupon', 'custom_woocommerce_empty_cart_button' );
function custom_woocommerce_empty_cart_button() {
	echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" class="button" title="' . esc_attr( 'Empty Cart', 'woocommerce' ) . '">' . esc_html( 'Empty Cart', 'woocommerce' ) . '</a>';
}

add_action( 'wp_loaded', 'custom_woocommerce_empty_cart_action', 20 );
function custom_woocommerce_empty_cart_action() {
	if ( isset( $_GET['empty_cart'] ) && 'yes' === esc_html( $_GET['empty_cart'] ) ) {
		WC()->cart->empty_cart();

		$referer  = wp_get_referer() ? esc_url( remove_query_arg( 'empty_cart' ) ) : wc_get_cart_url();
		wp_safe_redirect( $referer );
	}
}
Comment

remove add to cart woocommerce button

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');
Comment

woocommerce empty cart button

// adds the button to the cart page
add_action( 'woocommerce_cart_actions', 'woocommerce_empty_cart_button' );
function woocommerce_empty_cart_button() {
    echo '<a href="' . esc_url( add_query_arg( 'empty_cart', 'yes' ) ) . '" class="button" title="' . esc_attr( 'Empty Cart', 'woocommerce' ) . '">' . esc_html( 'Empty cart', 'woocommerce' ) . '</a>';
}

// empty the cart and refresh the page (redirects to the cart page)
add_action( 'wp_loaded', 'woocommerce_empty_cart_action', 20 );
function woocommerce_empty_cart_action() {
    if ( isset( $_GET['empty_cart'] ) && 'yes' === esc_html( $_GET['empty_cart'] ) ) {
        WC()->cart->empty_cart();
    
        $referer = wc_get_cart_url();
        wp_safe_redirect( $referer );
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: how to execute cmd command in php 
Php :: index.php wont load as main 
Php :: php call class dynamically 
Php :: wpdb num_rows 
Php :: sum of the array elements in php 
Php :: wp_get_attachment alt text 
Php :: cloudinary laravel 
Php :: php json_encode utf8 
Php :: Append a text string to WooCommerce single product title 
Php :: how to remove duplicate values from an array in php 
Php :: twig for loop key 
Php :: php extensions for apache2 
Php :: What does PEAR stands for? 
Php :: How to write a loop in PHP 
Php :: eloquent update row response 
Php :: php login google api 
Php :: subtract string php 
Php :: php best debugging functions 
Php :: curl get response headers php 
Php :: subdomain in laravel and xampp 
Php :: laravel target class does not exist 
Php :: larave Soft Deletes 
Php :: big int php 
Php :: run xampp application on windows startup 
Php :: send OTP php 
Php :: fresh migrqte laravel 
Php :: Adding data to a laravel collection 
Php :: Laravel: Validation unique on update 
Php :: get user information woocommerce 
Php :: php number format comma and decimal 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =