Created
August 22, 2012 09:08
-
-
Save ChromeOrange/3423933 to your computer and use it in GitHub Desktop.
Custom Add To Cart Messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom Add To Cart Messages | |
* Add this to your theme functions.php file | |
**/ | |
add_filter( 'woocommerce_add_to_cart_message', 'custom_add_to_cart_message' ); | |
function custom_add_to_cart_message() { | |
global $woocommerce; | |
// Output success messages | |
if (get_option('woocommerce_cart_redirect_after_add')=='yes') : | |
$return_to = get_permalink(woocommerce_get_page_id('shop')); | |
$message = sprintf('<a href="%s" class="button">%s</a> %s', $return_to, __('Continue Shopping →', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') ); | |
else : | |
$message = sprintf('<a href="%s" class="button">%s</a> %s', get_permalink(woocommerce_get_page_id('cart')), __('View Cart →', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') ); | |
endif; | |
return $message; | |
} | |
/* Custom Add To Cart Messages */ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about changing the html output of the
<a>
tag? I need to include an id and a custom data- attribute. E.gid="open_cart"
anddata-cart="opened"
- Manually setting these, just the id is returned.