久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

添加“查看產品"下面的按鈕添加到 WooCommer

Add quot;View Productquot; button below add to cart button in WooCommerce archives pages(添加“查看產品下面的按鈕添加到 WooCommerce 檔案頁面中的購物車按鈕)
本文介紹了添加“查看產品"下面的按鈕添加到 WooCommerce 檔案頁面中的購物車按鈕的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

互聯網上的大多數文章都是關于如何刪除/替換查看產品"或閱讀更多"按鈕.
我找不到與允許兩個按鈕一起使用的相關信息.

我有興趣讓兩個按鈕并行工作(同時).要顯示的第一個按鈕應該是查看產品"(在同一頁面上打開)然后在加入購物車"

下方

目前,我的商店只顯示加入購物車按鈕.我正在使用店面主題(+ 自定義子主題).

有沒有好心人告訴我怎么做?

解決方案

使用這個掛在 woocommerce_after_shop_loop_item 動作鉤子中的自定義函數,添加鏈接到產品的自定義按鈕(變量和分組產品類型除外):

add_action('woocommerce_after_shop_loop_item', 'add_a_custom_button', 5);函數 add_a_custom_button() {全球$產品;//不適用于沒有添加到購物車"按鈕的可變和分組產品if( $product->is_type('variable') || $product->is_type('grouped') ) return;//輸出鏈接到產品的自定義按鈕echo '<div style="margin-bottom:10px;"><a class="button custom-button" href="' .esc_attr( $product->get_permalink() ) .'">'.__('查看產品') .'</a>

';}

代碼位于活動子主題(或活動主題)的functions.php 文件中.

在 WooCommerce 3.7.x 上測試并仍然完美運行(使用最后一個店面主題):

<小時>

嵌入你的樣式(與作者評論相關):

add_action('wp_head', 'custom_button_styles', 9999);函數 custom_button_styles() {if( is_shop() || is_product_category() || is_product_tag() )://樣式?><風格>.button.custom-button { 背景顏色:白色!重要;顏色:黑色!重要;邊框:2px 實心 #4CAF50 !important;}.button.custom-button:hover { background-color: black !important;顏色:白色!重要;邊框:2px純黑色!重要;}</風格><?php萬一;}

代碼位于活動子主題(或主題)的 function.php 文件或任何插件文件中.

經過測試并有效.

Most of the articles on the internet are about How to remove / replace the "view product" or "read more" button.
I couldn't find something related to allowing both buttons working together.

I am interested in having both buttons working in parallel ( at the same time ). The first button to be displayed should be "View product" (to be opened on the same page) then underneath "Add to Cart"

At the moment, my store only displays the Add to cart button. I am using Storefront theme ( + custom child theme ).

Would anyone be so kind and tell me how to do this?

解決方案

Use this custom function hooked in woocommerce_after_shop_loop_item action hook, to add your custom button linked to the product (except variable and grouped product types):

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>';
}

Code goes in functions.php file of your active child theme (or active theme).

Tested and still perfectly works on WooCommerce 3.7.x (with last storefront theme):


Embedding your styles (related to author comments):

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;
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Tested and works.

這篇關于添加“查看產品"下面的按鈕添加到 WooCommerce 檔案頁面中的購物車按鈕的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產品的總訂單數)
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 九九爱这里只有精品 | 国产a级毛片 | 天天综合网天天综合色 | 欧美午夜一区 | 91资源在线观看 | 国产一区 | 小早川怜子xxxxaⅴ在线 | 玖玖国产 | 午夜三区 | 福利影院在线看 | 999www视频免费观看 | 天堂一区二区三区 | 偷拍自拍网址 | 国产精品自拍视频网站 | av大片在线观看 | av大片在线观看 | 国产福利在线播放麻豆 | 久国久产久精永久网页 | 国产精品91久久久久久 | 狠狠av| 一区二区三区四区在线 | 亚州成人 | 午夜a√ | 国产精品成人在线播放 | 成人欧美一区二区三区在线播放 | 涩爱av一区二区三区 | 久久91视频 | 性一爱一乱一交一视频 | 国产美女在线观看 | 日韩aⅴ视频 | 日韩在线一区二区 | 欧美亚州综合 | 中文字幕在线视频免费视频 | 国产精品久久久久久婷婷天堂 | 在线观看午夜视频 | 日韩免费毛片 | 成人免费小视频 | 国产精品亚洲成在人线 | 免费亚洲婷婷 | 欧美日韩手机在线观看 | 国产成人高清视频 |