• Resolved b2bwebteam

    (@b2bwebteam)


    Hello

    I’m trying to show my custom tab displaying ingredients on the packing slip which goes out to customers and I’m struggling to get it to show, I’ve tried a lot of different things (including some previous solutions on here for similar requests but for different areas) with no avail.

    On my packing slip, it display the product name and quantity above other information (SKU and Weight) and I want to show the product ingredients in this area, the code for this area is as follows;

    <tr class=”<?php echo apply_filters( ‘wpo_wcpdf_item_row_class’, $item_id, $this->type, $this->order, $item_id ); ?>”>
    <td class=”product”>
    <?php $description_label = __( ‘Description’, ‘woocommerce-pdf-invoices-packing-slips’ ); // registering alternate label translation ?>
    <span class=”item-name”><?php echo $item[‘name’]; ?></span>
    <?php do_action( ‘wpo_wcpdf_before_item_meta’, $this->type, $item, $this->order ); ?>
    <span class=”item-meta”><?php echo $item[‘meta’]; ?></span>
    <dl class=”meta”>
    <?php $description_label = __( ‘SKU’, ‘woocommerce-pdf-invoices-packing-slips’ ); // registering alternate label translation ?>
    <?php if( !empty( $item[‘sku’] ) ) : ?><dt class=”sku”><?php _e( ‘SKU:’, ‘woocommerce-pdf-invoices-packing-slips’ ); ?></dt><dd class=”sku”><?php echo $item[‘sku’]; ?></dd><?php endif; ?>
    <?php if( !empty( $item[‘weight’] ) ) : ?><dt class=”weight”><?php _e( ‘Weight:’, ‘woocommerce-pdf-invoices-packing-slips’ ); ?></dt><dd class=”weight”><?php echo $item[‘weight’]; ?><?php echo get_option(‘woocommerce_weight_unit’); ?></dd><?php endif; ?>
    </dl>
    <?php do_action( ‘wpo_wcpdf_after_item_meta’, $this->type, $item, $this->order ); ?>
    </td>
    <td class=”quantity”><?php echo $item[‘quantity’]; ?></td>
    </tr>

    I’m wondering if there’s any way I can manage to display my custom tab within this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hey @b2bwebteam,

    If you want to get your tabs data to use elsewhere you can just pull the post meta. I see in your example you have an $item_id variable. If that’s the product ID you would just do this:

    $tabs = get_post_meta( $item_id, 'yikes_woo_products_tabs', true );

    That would give you an array of tabs for the product.

    Once you have the tabs you could modify this snippet to mark them up how you’d like:

    
    $html = '';
    
    // Loop through the tabs and display each one
    foreach( $tabs as $tab ) {
    	$html .= '<p>' . $tab['title'] . '</p>';
    	$html .= '<p>' . $tab['content'] . '</p>';
    }
    

    The code that I’m referring to here is actually part of a shortcode example that we’ve done previously:
    https://wordpress.org/support/topic/tab-content-shortcode/

    Hope this helps!

    Cheers,
    Freddie

    Thread Starter b2bwebteam

    (@b2bwebteam)

    Hi Freddie

    Thanks for this, but I’m still a little lost unfortunately. PHP isn’t my strongest point and I’m usually much more comfortable working behind the guise of a WordPress editor or in some cases using CSS to make minor changes, this would be by far the most complicated link I’ve had to make.

    Is there any way you would be able to advise on the code I would need to use to get this to display, similar the code displaying the SKU and the weight of the product?

    <?php if( !empty( $item[‘sku’] ) ) : ?><dt class=”sku”><?php _e( ‘SKU:’, ‘woocommerce-pdf-invoices-packing-slips’ ); ?></dt><dd class=”sku”><?php echo $item[‘sku’]; ?></dd><?php endif; ?>

    <?php if( !empty( $item[‘weight’] ) ) : ?><dt class=”weight”><?php _e( ‘Weight:’, ‘woocommerce-pdf-invoices-packing-slips’ ); ?></dt><dd class=”weight”><?php echo $item[‘weight’]; ?><?php echo get_option(‘woocommerce_weight_unit’); ?></dd><?php endif; ?>

    @b2bwebteam,

    Long story short, if you’re not familiar with PHP its going to be a pretty hard lift for you to pull something like this off. Not impossible though, you could actually take this code that I’ve written for Divi and place it in your functions.php file to create the shortcode.

    You’ll only need from line 7 down:
    https://github.com/yikesinc/divi-child-custom-tabs/blob/master/functions.php

    If you don’t know how to add php code to your theme you can use this plugin:
    https://wordpress.org/plugins/my-custom-functions/

    Cheers,

    Freddie

    • This reply was modified 3 years, 8 months ago by Freddie. Reason: typo
    Thread Starter b2bwebteam

    (@b2bwebteam)

    Hi Freddie

    I can add that bit with no issue, it’s then figuring out how to make it display in a similar way to the SKU and the weight on the actual report that it gives that is confusing me

    Plugin Contributor Tracy Levesque

    (@liljimmi)

    🏳️‍🌈 YIKES, Inc. Co-Owner

    Hi @b2bwebteam

    You may have to hire someone who is familiar with PHP and WordPress development.

    The scope of your project may be beyond what we can do via the free support forums.

    Best of luck and stay well!
    -Tracy

    Thread Starter b2bwebteam

    (@b2bwebteam)

    Hi @liljimmi

    I may have to look into it, my query was more down the lines of how to display the shortcode via PHP from that last point.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Show custom tab on packing slip’ is closed to new replies.