[Special Summer Sale] 40% OFF All Magento 2 Themes

Cart

Hide custom DIV CSS on product listings to a single product in WordPress

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8944
    David Hoang
    Keymaster

    I have resolve it.

     <div class="EMP-100-TAW-Craciun-Produs-I">
              <?php
              
            
    
        if ( get_the_ID() === 1744) { $product;
        $regular_price = esc_attr( $product->get_display_price() );
        $discount = 10;
        $currency = esc_attr( get_woocommerce_currency() );
        $new_price = $regular_price - ($regular_price * 0.10);
    
        echo 'Cumpără acest produs cu doar <span style="
        font-size: 20px;
        color: red;
    ">'.$new_price.$currency.'</span> prin Cadoul TAW de Crăciun';
    
        }
    
    
    ?>
    
    </div>
    

    I want in pagination, category listings to hide a custom div using PHP code,
    For one particular product I want my div below title to have display: none;

    I have this code but it apply to all products listings?

    Any idea’s? Thanks!

       <div class="EMP-100-TAW-Craciun-Produs-I">
              <?php
    
        global $product;
        $regular_price = esc_attr( $product->get_display_price() );
        $discount = 10;
        $currency = esc_attr( get_woocommerce_currency() );
        $new_price = $regular_price - ($regular_price * 0.10);
    
        echo 'Cumpără acest produs cu doar <span style="
        font-size: 20px;
        color: red;
    ">'.$new_price.$currency.'</span> prin Cadoul TAW de Crăciun';
    
    
    
    
    ?>
    
    </div>
    <?php
    
        if ( get_the_ID() === 1744) {
        echo "<style>.EMP-100-TAW-Craciun-Produs-I {
        display: none;
    }</style>";
    } 
    else{
         echo "<style>.EMP-100-TAW-Craciun-Produs-I {
        display: inherit;
    }</style>";
    }
    
    ?>
    
    #8945
    David Hoang
    Keymaster

    I would do the following:

    <?php if(get_the_ID() == 1744) { ?>
    <div class="EMP-100-TAW-Craciun-Produs-I">
        <!-- ... -->
    </div>
    <?php } ?>
    

    like so I would get the whole div only if the ID is 1744 and i need no display: none

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.