dongxing7083 2018-08-31 18:27
浏览 61


I need to do some styling to the Woocommerce single product page: I need a border around the price(which I moved above the add to cart button), in stock status, add to cart button and meta data. So basically a visual border around these items:

Since they are not in one specific div, I need to place a new div around them. How can I add this div around the above mentioned items?

  • 写回答

2条回答 默认 最新

  • doom910730 2018-08-31 20:17


    If you have moved the product price above add to cart button with some code, the following code bellow will replace your code as it also move the price under product short description.

    It also adds a div container html tag starting before the moved price and ending after the product meta data (see the screenshot at the end).

    The code:

    add_action('woocommerce_single_product_summary', 'custom_single_product_price', 3 );
    function custom_single_product_price() {
        // Remove product price
        remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
        // Add back the product price after short description
        add_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 25 );
        // Opening div container (just after the product short description and before the moved product price)
        add_action('woocommerce_single_product_summary', 'opening_div_single_product_summary', 21 );
        // Closing div container (after the product meta data)
        add_action('woocommerce_single_product_summary', 'closing_div_template_single_price', 60 );
    function opening_div_single_product_summary() {
        // Display the opening div
        echo '<div class="custom-container">';
    function closing_div_template_single_price() {
        // Then display the closing div
        echo '</div>';

    Code goes in function.php file of the active child theme (or active theme). tested and works.

    enter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥20 Apache poi使用问题
  • ¥21 matlab怎么求时域信号的二阶导数
  • ¥15 判断两个表是否完全相同
  • ¥15 java map类型数据格式,如何快速通过前缀匹配元素
  • ¥15 stc12c5a60s2、QMC5883L、LCD1602组合测量磁场所需程序
  • ¥20 Win11测试yolov4,“找不到nvcuda.dll”怎么办?
  • ¥15 simulink绘制bode图
  • ¥15 php_network_getaddresses: getaddrinfo failed: Name or service not known
  • ¥15 用msg发消息出现的问题
  • ¥15 unity3d机械臂