1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Removing the space line

Discussion in 'HTML & Website Design' started by dabidovic123, Jul 30, 2022.

  1. #1
    Hi,

                ?>
                <h2 class="email-upsell-title"><?php esc_html_e( 'Tracking information:', 'woo-orders-tracking' ) ?></h2>
    
                <?php
                $text = '';
                foreach ( $tracking_info as $item ) {
                    $text .= ', <a href="' . $item['tracking_url'] . '" target="_blank">' . $item['tracking_code'] . '</a>' . esc_html__( ' by ', 'woo-orders-tracking' ) . $item['carrier_name'];
                }
                $text = trim( $text, ',' );
                echo '<p>' . esc_html__( 'Your tracking number: ', 'woo-orders-tracking' ) . $text . '</p>';
                $html = ob_get_clean();
                echo ent2ncr( $html );
    PHP:

    Currently, the above code displays the notification in emails like this:
    -
    Tracking Information:

    Your tracking number: HY2587349PO by DHL
    -

    I want to display it like this by removing the space line:
    -
    Tracking information:
    Your tracking number: HY2587349PO by DHL
    -

    How can I change the code to remove this space between the two lines?

    Thank you,
     
    dabidovic123, Jul 30, 2022 IP
  2. hdewantara

    hdewantara Well-Known Member

    Messages:
    536
    Likes Received:
    47
    Best Answers:
    25
    Trophy Points:
    155
    #2
    Hi, I think of one way which is through CSS:
    h2.email-upsell-title{
      margin-bottom: 0;
    }
    Code (CSS):
     
    hdewantara, Jul 30, 2022 IP
    sarahk likes this.
  3. dabidovic123

    dabidovic123 Greenhorn

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    Thanks for your reply, @hdewantara,
    but I need a code that is inserted inside the above code.
     
    dabidovic123, Jul 30, 2022 IP
  4. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #4
    You can then add style="" next to your class, like so:

    <h2 class="email-upsell-title" style="margin-bottom:0; padding-bottom:0"><?php esc_html_e( 'Tracking information:', 'woo-orders-tracking' ) ?></h2>
    Code (markup):
    Also, if it still has a space remove the <p></p> and just put a <br> at the end of it:

    echo '' . esc_html__( 'Your tracking number: ', 'woo-orders-tracking' ) . $text . '<br>';
    Code (markup):
    See if does what you want it to do:

    ?>
    <h2 class="email-upsell-title" style="margin-bottom:0; padding-bottom:0"><?php esc_html_e( 'Tracking information:', 'woo-orders-tracking' ) ?></h2>
    
    <?php
    $text = '';
    foreach ( $tracking_info as $item ) {
    $text .= ', <a href="' . $item['tracking_url'] . '" target="_blank">' . $item['tracking_code'] . '</a>' . esc_html__( ' by ', 'woo-orders-tracking' ) . $item['carrier_name'];
    }
    $text = trim( $text, ',' );
    echo '' . esc_html__( 'Your tracking number: ', 'woo-orders-tracking' ) . $text . '<br>';
    $html = ob_get_clean();
    echo ent2ncr( $html );
    Code (markup):
     
    qwikad.com, Jul 30, 2022 IP
  5. dabidovic123

    dabidovic123 Greenhorn

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #5
    Thanks, @qwikad.com for your replay,
    I used
    style="margin-bottom:0; padding-bottom:0"
    Code (CSS):
    , and it works.
    The spacing is removed.

    Thank you for your help,
    Have a great day,
     
    dabidovic123, Jul 30, 2022 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #6
    Valid answers from @hdewantara & @qwikad.com.

    H2 will have a margin-bottom by design, if you don't want that you'll always have to use CSS to change it. Rethink your use of H2.
     
    sarahk, Jul 30, 2022 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #7
    No, you REALLY don't. And if you do, it would mean you do not have access to where such changes should be made. In the stylesheet.

    Though really that markup needs to be thrown in the trash. As I'm always saying 90% or more of the time you see style="", you're looking at ignorance, incompetence, or ineptitude since what things look like has NO business in the markup.

    Much like that code slopping out a stream of anchors with no block level dividers or semantics to explain what they are for, the garbage target attribute being abused to shove new windows down users gullets whether they want it or not, the variables for nothing, output buffering for who knows what likely meaning you can't gzip the result, variables for nothing...

    Damn that's horrifying.
     
    deathshadow, Aug 1, 2022 IP
  8. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #8
    Guessing WILDLY -- been decades since I dealt with the shitshow that is turdpress, and by extension wooCommerce.

    
    <?php
    
    	echo '
    		<h2>
    			', esc_html_e( 'Tracking information:', 'woo-orders-tracking' ), '
    		</h2>
    		
    		<h3>
    			', esc_html__( 'Your tracking number(s): ', 'woo-orders-tracking' ), '
    		</h3>
    		<ul class="trackingNumbers">';
    	
    	foreach ($tracking_info as $item) echo '
    			<li>
    				<a href="', $item['tracking_url'], '">
    					', $item['tracking_code'], '
    				</a>
    				', esc_html__('by ','woo-orders-tracking'), $item['carrier_name'], '
    			</li>';
    	}
    	
    	echo '
    		</ul>';
    	
    	$html = ob_get_clean();
    	echo ent2ncr( $html );
    
    Code (markup):
    Is probably what I'd write there. Anything to do with appearance? That's the stylesheet's job. For example to turn that UL into a comma delimited list...

    
    .trackingNumbers li {
    	display:inline;
    }
    
    .trackingNumbers li:not(:first-child):before {
    	content:", ";
    }
    
    Code (markup):
    Thus you have proper semantics for all users, and your comma delimited result for screen users without a bunch of string manipulation BS games wasting the server's time.

    I guessed on the heading levels since the second one doesn't seem to be a paragraph, it's a heading for the LIST of numbers that follows.

    Semantic markup WITHOUT giving a flying purple fish what things look like FIRST. Then you style it FROM YOUR STYLESHEET, not in the bloody markup!
     
    Last edited: Aug 1, 2022
    deathshadow, Aug 1, 2022 IP
    Sumit_Singh and sarahk like this.