如何将我创建的一个产品制作到 woocommerce 商店页面?
How do I make the one product I created to woocommerce shop page?
我们目前只有一种产品。我希望我们的产品成为商店页面。你知道我如何将我创建的产品制作到购物页面吗?如果用户点击商店,它应该只显示我的单一产品。不是产品列表,因为我们只有一种产品。产品意味着它在该页面中有添加到购物车按钮。所以商店页面应该显示带有添加到购物车按钮、产品信息、价格等所有内容的产品页面。
例如,我希望用户点击商店页面应该 link 到我的单个页面,就像这样。
http://www.garageclothing.com/us/hooded-flannel-plaid-shirt/p/100009673
我认为您应该能够过滤 template_redirect
。
function so_template_redirect(){
if( function_exists( 'is_shop' ) && is_shop() ){
$product_id = 999; // change to the ID of your 1 product
$permalink = get_permalink( $product_id );
wp_redirect( $permalink );
exit();
}
}
add_action( 'template_redirect', 'so_template_redirect' );
我们目前只有一种产品。我希望我们的产品成为商店页面。你知道我如何将我创建的产品制作到购物页面吗?如果用户点击商店,它应该只显示我的单一产品。不是产品列表,因为我们只有一种产品。产品意味着它在该页面中有添加到购物车按钮。所以商店页面应该显示带有添加到购物车按钮、产品信息、价格等所有内容的产品页面。
例如,我希望用户点击商店页面应该 link 到我的单个页面,就像这样。 http://www.garageclothing.com/us/hooded-flannel-plaid-shirt/p/100009673
我认为您应该能够过滤 template_redirect
。
function so_template_redirect(){
if( function_exists( 'is_shop' ) && is_shop() ){
$product_id = 999; // change to the ID of your 1 product
$permalink = get_permalink( $product_id );
wp_redirect( $permalink );
exit();
}
}
add_action( 'template_redirect', 'so_template_redirect' );