Home Change add to cart is_purchasable notice in Woocommerce
Reply: 0

Change add to cart is_purchasable notice in Woocommerce

user792
1#
user792 Published in April 24, 2018, 6:43 am

I would like to change the notice 'Sorry, this product cannot be purchased' to 'Sorry, the product [product name] cannot be purchased.'

I've found it in the WC_Cart add_to_cart() method source code and below it's an extract of what I would like to change:

if ( ! $product_data->is_purchasable() ) {
   #the current line
   #throw new Exception( __( 'Sorry, this product cannot be purchased.', 'woocommerce' ) ); 
   # i want to replace for this one
   throw new Exception(sprintf( __( 'Sorry, the product "%s" cannot be purchased.', 'woocommerce' ),  $product_data->get_name() ) );
}

Is there a way to do this in a hook or filter or something in my functions.php file?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.318265 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO