如何在单个产品页面上的添加到购物车按钮旁边添加货币切换器下拉菜单?
How to add Currency Switcher Drop down menu next to Add to Cart Button on Single Product page?
您好,我有这个网站 www.gallery5designs.com,这是一个 link 样品产品 http://gallery5designs.com/product/necklace-18k-white-gold-plating-aaa-cubic-zerconia/
我有一个名为 "WooCommerce Currency Switcher" 的插件,它可以在任何地方显示货币切换选项。但问题是..那个插件只提供一个简码来嵌入任何地方或一个小部件,但我希望那个货币切换器出现在网络上以添加到购物车按钮。我正在为这个网站使用 Betheme 的子主题。谁能帮我解决这个问题?
以下代码在单个产品页面上的添加到购物车按钮附近输出货币切换器表单。但是,您需要根据需要通过 css 设置样式。
此代码需要放入您的主题“s/child-theme”的 functions.php 文件中。
add_action('woocommerce_single_product_summary','woocs_custom_location',35);
function woocs_custom_location(){
$plugin_var= "woocommerce-currency-switcher";
if (in_array( $plugin_var.'/index.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ){
echo(do_shortcode('[woocs]'));
}
}
我已经在我的 woocommerce 设置中尝试和测试了这个。希望这有帮助。
您好,我有这个网站 www.gallery5designs.com,这是一个 link 样品产品 http://gallery5designs.com/product/necklace-18k-white-gold-plating-aaa-cubic-zerconia/
我有一个名为 "WooCommerce Currency Switcher" 的插件,它可以在任何地方显示货币切换选项。但问题是..那个插件只提供一个简码来嵌入任何地方或一个小部件,但我希望那个货币切换器出现在网络上以添加到购物车按钮。我正在为这个网站使用 Betheme 的子主题。谁能帮我解决这个问题?
以下代码在单个产品页面上的添加到购物车按钮附近输出货币切换器表单。但是,您需要根据需要通过 css 设置样式。 此代码需要放入您的主题“s/child-theme”的 functions.php 文件中。
add_action('woocommerce_single_product_summary','woocs_custom_location',35);
function woocs_custom_location(){
$plugin_var= "woocommerce-currency-switcher";
if (in_array( $plugin_var.'/index.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ){
echo(do_shortcode('[woocs]'));
}
}
我已经在我的 woocommerce 设置中尝试和测试了这个。希望这有帮助。