In this tutorial we learn how to redirect shop page to specific page
// Redirect WooCommerce Shop URL
function wc_shop_url_redirect() {
if( is_shop() ){
wp_redirect( home_url( '/tutorials/' ) ); // Assign custom internal page here
exit();
}
}
add_action( 'template_redirect', 'wc_shop_url_redirect' )
Woocommerce is best plugin in current market after it's sucess lots of demand
we cover in this articale how to add/remove fuctionality in woocommerce theme, these code snippets help you building your dynamic site
code is used for declaring WooCommerce support in your theme
function woocommerce_support() {
add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'woocommerce_support' );
you can replace woocommerce default shop page via WC snippet
function wc_shop_page_title( $page_title ) {
if( 'Shop' == $page_title) {
return "Usercode shop";
}
}
add_filter( 'woocommerce_page_title', 'wc_shop_page_title');
Single page cart button text change code
/ To change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' );
function woocommerce_custom_single_add_to_cart_text() { return __( 'Buy Now', 'woocommerce' ); }
WC Archive page button text change
// To change add to cart text on product archives page
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );
function woocommerce_custom_product_add_to_cart_text() { return __( 'Buy Now', 'woocommerce' );}
function add_to_cart_checkout_redirect() {
wp_safe_redirect( get_permalink( get_option( 'woocommerce_checkout_page_id' ) ) );
die();
}
add_action( 'woocommerce_add_to_cart', 'add_to_cart_checkout_redirect', 16 );