Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在WooCommerce归档页面的“添加到购物车”按钮下方添加“查看产品”按钮_Php_Wordpress_Woocommerce_Hook Woocommerce_Storefront - Fatal编程技术网

Php 在WooCommerce归档页面的“添加到购物车”按钮下方添加“查看产品”按钮

Php 在WooCommerce归档页面的“添加到购物车”按钮下方添加“查看产品”按钮,php,wordpress,woocommerce,hook-woocommerce,storefront,Php,Wordpress,Woocommerce,Hook Woocommerce,Storefront,internet上的大多数文章都是关于如何删除/替换“查看产品”或“阅读更多”按钮的。 我找不到与允许两个按钮同时工作相关的内容 我对两个按钮同时并行工作感兴趣。 要显示的第一个按钮应该是在同一页面上打开的“查看产品”,然后在“添加到购物车”下面 目前,我的商店只显示“添加到购物车”按钮。 我正在使用店面主题+自定义子主题 有谁能告诉我怎么做吗?使用woocommerce\u after\u shop\u loop\u item操作挂钩中的自定义功能,添加链接到产品的自定义按钮,变量和分组产品类

internet上的大多数文章都是关于如何删除/替换“查看产品”或“阅读更多”按钮的。 我找不到与允许两个按钮同时工作相关的内容

我对两个按钮同时并行工作感兴趣。 要显示的第一个按钮应该是在同一页面上打开的“查看产品”,然后在“添加到购物车”下面

目前,我的商店只显示“添加到购物车”按钮。 我正在使用店面主题+自定义子主题


有谁能告诉我怎么做吗?

使用woocommerce\u after\u shop\u loop\u item操作挂钩中的自定义功能,添加链接到产品的自定义按钮,变量和分组产品类型除外:

代码进入活动子主题或活动主题的functions.php文件

经过测试,在WooCommerce 3.7.x上仍能完美运行,最后一个店面主题:

嵌入与作者注释相关的样式:

代码位于活动子主题或主题的function.php文件中,或者位于任何插件文件中


已测试并正常工作。

使用woocommerce\u after\u shop\u loop\u项目操作挂钩中的此自定义功能,添加链接到产品的自定义按钮,变量和分组产品类型除外:

代码进入活动子主题或活动主题的functions.php文件

经过测试,在WooCommerce 3.7.x上仍能完美运行,最后一个店面主题:

嵌入与作者注释相关的样式:

代码位于活动子主题或主题的function.php文件中,或者位于任何插件文件中


经过测试,效果良好。

令人惊讶的是,它确实有效。非常感谢你!另一个问题,是否可以单独编辑此按钮的背景颜色和文本颜色?谢谢,我注意到两个按钮之间有一个很大的间隙,这个距离可以缩短吗?谢谢谢谢,系统不允许我发布新问题新帐户,除了这个原始问题被否决。所以我在style.css中添加了这个在子主题中:自定义按钮{背景色:白色;颜色:黑色;边框:2px实心4CAF50;/*绿色*/}但是,没有显示upil ne FONCONONNE pas。我在想按钮的类名是否有问题。是否可以将这个新的自定义按钮命名为custom-button1?像这样的。太棒了,它能用。非常感谢你!另一个问题,是否可以单独编辑此按钮的背景颜色和文本颜色?谢谢,我注意到两个按钮之间有一个很大的间隙,这个距离可以缩短吗?谢谢谢谢,系统不允许我发布新问题新帐户,除了这个原始问题被否决。所以我在style.css中添加了这个在子主题中:自定义按钮{背景色:白色;颜色:黑色;边框:2px实心4CAF50;/*绿色*/}但是,没有显示upil ne FONCONONNE pas。我在想按钮的类名是否有问题。是否可以将这个新的自定义按钮命名为custom-button1?像这样的。
add_action('woocommerce_after_shop_loop_item', 'add_a_custom_button', 5 );
function add_a_custom_button() {
    global $product;

    // Not for variable and grouped products that doesn't have an "add to cart" button
    if( $product->is_type('variable') || $product->is_type('grouped') ) return;

    // Output the custom button linked to the product
    echo '<div style="margin-bottom:10px;">
        <a class="button custom-button" href="' . esc_attr( $product->get_permalink() ) . '">' . __('View product') . '</a>
    </div>';
}
add_action('wp_head', 'custom_button_styles', 9999 );
function custom_button_styles() {
    if( is_shop() || is_product_category() || is_product_tag() ):

    // The styles
    ?>
    <style>
        .button.custom-button { background-color: white !important;
            color: black !important; border: 2px solid #4CAF50 !important; }
        .button.custom-button:hover { background-color: black !important;
            color: white !important; border: 2px solid black !important; }
    </style>
    <?php
    endif;
}