Home New Guten Forums WoodMart support forum Add custom class before and after some classes by code

Add custom class before and after some classes by code

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #268398

    atpd23
    Participant

    Hello,

    I need to put classes ‘price’ and ‘cart’ into a new class. I need to add border around these two classes, so maybe adding them into a new class could solve the problem.

    I have tried to make it by my own, I have added a class before and after add to cart button (filled red rectangle in the image), but that’s not the result I would expected. Maybe the addition of class’s opening tag before ‘price’ and class’s close tag after ‘cart’ could solve my problem.

    To clarify, I would need to add class’s open tag before ‘price’ class and class’s close tag after ‘cart’ class – please see the image.

    Best Regards

    —————————-

    I have tried this code, but it doesn’t do what I need to:

    add_action( 'woocommerce_before_add_to_cart_button', 'add_content_before_addtocart_button_func' );
    function add_content_before_addtocart_button_func() {
            // Echo content.
            echo '<span class="classname">';
    }
    
    add_action( 'woocommerce_after_add_to_cart_button', 'add_content_after_addtocart_button_func' );
    function add_content_after_addtocart_button_func() {
            // Echo content.
            echo '</span>';
    }
    Attachments:
    You must be logged in to view attached files.
    #268503

    Hello,

    Please add this code to functions.php of the child theme:

    add_action(
       'woocommerce_single_product_summary',
       function() {
          echo '<div class="test">';
       },
       9
    );
    add_action(
       'woocommerce_single_product_summary',
       function() {
          echo '</div>';
       },
       31
    );

    Best Regards

    #268504

    You will get this result: http://prntscr.com/103wa1v

    Best Regards

Viewing 3 posts - 1 through 3 (of 3 total)