I need help!
I removed the "add to cart" button from my main store page because "see items" makes more sense in this case.
here is the code I added to my child functions.php theme:
`
function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
add_action('init','remove_loop_button');
add_action('woocommerce_after_shop_loop_item','replace_add_to_cart');
function replace_add_to_cart() {
global $product;
$link = $product->get_permalink();
$text = _( 'See Items');
echo '<a href="'.$link.'" class="button addto_cart_button">See Items</a>';
}
` It swaps out the button correctly on the main shop page but in the single post, the upsell also shows "see items" when I want it to say "add to cart" ... I have tried everything.
UPDATE: solved i think? it works, anyway :-)
// add add to cart back to upsell
' remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_upsells', 15 );
if ( ! function_exists( 'woocommerce_output_upsells' ) ) {
if ( ! function_exists( 'woocommerce_output_upsells' ) ) {
function woocommerce_output_upsells() {
remove_action('woocommerce_after_shop_loop_item', 'replace_add_to_cart');
add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
}
}
} '