• Resolved cycloneuk

    (@cycloneuk)


    I want to remove the sku and weight from the packing slip, I saw this code and it works to remove the sku but even if I add weight to .product .meta .sku .weight it dosen’t work. I can remove 1 or the other but not both.

    add_action( 'wpo_wcpdf_custom_styles', 'wpo_wcpdf_custom_styles', 10, 2 );
    function wpo_wcpdf_custom_styles ( $document_type, $document ) {	
      if ($document_type == 'packing-slip'){
        ?>
        .product .meta .sku
    {
         display:none; 
    
        }	
        <?php
      }
    }
    
    
    
    • This topic was modified 2 years, 8 months ago by cycloneuk.
Viewing 1 replies (of 1 total)
  • Plugin Contributor Darren Peyou

    (@dpeyou)

    Hey @cycloneuk,

    The code snippet shared by my colleague here should work just fine for your needs. 🙂

    Your CSS selectors are not correct for targeting both elements (weight & sku). You need to have CSS selectors for each target, separated by a comma.

    – CSS selector for SKU:

    .product .meta .sku


    – CSS selector for Weight:

    .product .meta .weight


    So now if you go back to my colleagues code, you will notice that both CSS selectors are separated by a comma:. That means that the rule is applied to both selectors. The rule here is display: none;

    add_action( 'wpo_wcpdf_custom_styles', 'wpo_wcpdf_custom_styles', 10, 2 );
    function wpo_wcpdf_custom_styles ( $document_type, $document ) { 
    	if ( $document_type == 'packing-slip' ) { 
    	?> 
    
    		.product .meta .sku, 
    		.product .meta .weight { 
    			display: none; 
    		} 
    		
    	<?php 
    	} 
    }

    This part below ensures that only the Packing Slip PDF is targeted by our code:
    if ( $document_type == 'packing-slip' ) {

Viewing 1 replies (of 1 total)

The topic ‘Remove SKU and Weight’ is closed to new replies.