WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce Print Invoice & Delivery Note
[Plugin: WooCommerce Print Invoices & Delivery Notes] Custom Fields + Delivery Notes & Invoi (2 posts)

  1. jigsgfx
    Member
    Posted 1 year ago #

    Hi, im a fully newbie on PHP i add a checkout page custom field on my theme custom-functions.php that i get from woocommerce support docs.. here's the code i use it to add a custom Delivery Date on my Checkout page.

    /**
     * Add the field to the checkout DELIVERY DATE
     **/
    add_action('woocommerce_after_order_notes', 'delivery_date_field');
    
    function delivery_date_field( $checkout ) {
    
        echo '<div id="delivery_date_field"><h3>'.__('Delivery Date/Time (optional)').'</h3>';
    
        woocommerce_form_field( 'delivery_date', array(
            'type'          => 'text',
            'class'         => array('delivery-date form-row-wide'),
            'label'         => __(' - use this for future delivery eg. October 12, 2020 - 10:00PM'),
            'placeholder'       => __('Input date&time here TYPE Month Day & Year - TIME'),
            ), $checkout->get_value( 'delivery_date' ));
    
        echo '</div>';
    
    }
    
    /**
     * Process the checkout
     **/
    add_action('woocommerce_checkout_process', 'delivery_date_field_process');
    
    function delivery_date_field_process() {
        global $woocommerce;
    
    }
    
    /**
     * Update the order meta with field value
     **/
    add_action('woocommerce_checkout_update_order_meta', 'delivery_date_field_update_order_meta');
    
    function delivery_date_field_update_order_meta( $order_id ) {
        if ($_POST['delivery_date']) update_post_meta( $order_id, 'Delivery Date', esc_attr($_POST['delivery_date']));
    }
    
    /**
     * Add the field to order emails
     **/
    add_filter('woocommerce_email_order_meta_keys', 'delivery_date_field_order_meta_keys');
    
    function delivery_date_field_order_meta_keys( $keys ) {
    	$keys[] = 'Delivery Date';
    	return $keys;
    }

    and im wondering on how i can add the Delivery Date under Order Date on delivery notes & invoice when printing it.

    thanks in advance :D

    http://wordpress.org/extend/plugins/woocommerce-delivery-notes/

  2. ashokrane
    Member
    Posted 1 year ago #

    I have created Order Delivery Date plugin which you can use rather than custom code. It will allow you to put the delivery date field on the checkout page & also control the dates. Check out the latest version of the plugin at:

    http://www.tychesoftwares.com/store/premium-plugins/order-delivery-date-for-wp-e-commerce-woocommerce-pro

    Currently the date is not sent in the invoice when emailing it, I have planned that for a future release.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic