Created
June 5, 2014 21:02
-
-
Save roykho/ec36afdf004f5efcf7a9 to your computer and use it in GitHub Desktop.
WooCommerce: Link external products to detail product page from product category list
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
add_filter( 'woocommerce_loop_add_to_cart_link', 'product_cat_external', 10, 2 ); | |
function product_cat_external( $html, $product ) { | |
if ( $product->product_type === 'external' ) { | |
return '<a href="' . get_post_permalink( $product->id ) . '" rel="nofollow" data-product_id="' . esc_attr( $product->id ) . '" data-product_sku="' . esc_attr( $product->get_sku() ) . '" class="button add_to_cart_button product_type_variable">View Detail</a>'; | |
} else { | |
return $html; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment