Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! It depends on how the delivery date and time are stored in the order. Basically you can call them from the order as custom fields. There’s an example here, but you probably need to replace the ‘delivery_date’ custom field name with whatever was used when storing the date. If this is stored by a plugin, the plugin developer should be able to help!

    Let me know if you have any other questions!

    Ewout

    Hi Ewout,

    I’m using this plugin for implementing delivery slots – https://codecanyon.net/item/woocommerce-delivery-slots/7323634

    Custom fields used by this plugin are – jckwds_date (For date) and jckwds_timeslot (for time)

    And this is the code in functions.php to print the delivery slot in PDF invoice which is generated using your plugin.

    add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_delivery_date', 10, 2 );
    function wpo_wcpdf_delivery_date ($template_type, $order) {
        global $wpo_wcpdf;
        if ($template_type == 'packing-slip') {
            ?>
            <tr class="delivery-date">
                <th>Delivery Date:</th>
                <td><?php $wpo_wcpdf->custom_field('jckwds_date'); ?></td>
            </tr>
    	<tr class="delivery-date">
                <th>Time Slot:</th>
                <td><?php $wpo_wcpdf->custom_field('jckwds_timeslot'); ?></td>
            </tr>
    
            <?php
        }
    }

    The code is apparently for packing-slip, so the delivery time and slot is not printed on the invoice.
    Is the code correct ? Can you verify, please.

    For past few days when I click download invoice or packing slip it is taking indefinite time to start download. I have allocated 512 MB for wordpress and php. So, no bottlenecks in server side. My site is hosted with AWS, so no issues with slow server. \

    But the invoice email generated by woocommerce contains the pdf invoice attached.

    As a result I cannot download the packing slip and test. So, I replaced teplate_type=’invoice’ and resent the customer invoice, but still the pdf invoice emailed didn’t contain the time slot.

    Let me know how can I print the delivery time slot and date in the pdf invoice and what is the issue with downloading packing-slip and invoice.

    Do I have to deactivate all plugins and remove all customizations related to your plugin and test again ?

    What do you suggest ?

    Plugin Contributor Ewout

    (@pomegranate)

    Hi!
    First of all, to get the delivery date on both the invoice and the packing slip, you can remove the template type condition altogether:

    add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_delivery_date', 10, 2 );
    function wpo_wcpdf_delivery_date ($template_type, $order) {
        global $wpo_wcpdf;
        ?>
        <tr class="delivery-date">
            <th>Delivery Date:</th>
            <td><?php $wpo_wcpdf->custom_field('jckwds_date'); ?></td>
        </tr>
        <tr class="delivery-date">
            <th>Time Slot:</th>
            <td><?php $wpo_wcpdf->custom_field('jckwds_timeslot'); ?></td>
        </tr>
    
        <?php
    }

    I just tested this on my own site (created those custom fields manually because I don’t have that plugin), and it didn’t choke.

    You don’t have to deactivate all plugins right away, I would start with reverting to the default Simple template and deactivating all other hooks/customizations that you have put in your theme functions relating to the PDF invoices. Then you can work your way from there.

    If that doesn’t solve the issue, I would indeed deactivate all plugins and activate them one by one to find which one is causing the hang.

    Let me know if that helps!

    Ewout

    Hey Ewout,

    Thanks for the suggestion. I deactivated all plugins and customizations related to your plugin and checked the code syntax and dependencies and now I’m able to download the invoice and packing slip’s without any lag. As per my function, I could test that Delivery time slot and date was printed on packing slip and not on the invoice. With your code, I can get the Delivery slot and date printed on both packing slip and invoice.

    Thanks for the help.

    Plugin Contributor Ewout

    (@pomegranate)

    You’re welcome, glad to hear you were able to resolve the issue!

    Ewout

    Hey,

    I am using this plugin for delivery details.

    I want day of week from selected delivery date but I just got one day thursday in any date of the month.

    This is my code:

    <?php _e( ‘Delivery Day:’, ‘wpo_wcpdf’); ?></th>
    <td><?php $unFormate = $wpo_wcpdf->custom_field(‘jckwds_date’);
    $get = explode(“/”,”$unFormate”);
    $dates = $get[2].”-“.$get[1].”-“.$get[0];
    $weekday = date(‘l’, strtotime($dates)); // note: first arg to date() is lower-case L
    echo $weekday;
    ?>

    How can we get the right day of the week?

    Thank You.

    Plugin Contributor Ewout

    (@pomegranate)

    Hi!
    Without knowing what the date is initually formatted like, it’s impossible for me to know why this is not working. I suspect that strtotime() will recognize the format directly though, so why not use that instead of converting it?
    You’re also using the display function custom_field() rather than the get function get_custom_field.

    try this:

    $delivery_date = $wpo_wcpdf->get_custom_field('jckwds_date');
    echo date('l', strtotime($delivery_date));

    Hope that helps! If not, let me know the exact input and output you’re working with/getting.

    Ewout

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Display delivery date and time slot’ is closed to new replies.