• Resolved LimingYun

    (@limingyun)


    Hello,

    I am trying to add a custom date : would need date + 5 days.

    Is it possible to create a new meta field by using order date meta key and add 5 days to it ?

    Actually, it is for fresh products. My delivery application absolutely need that my orders CSV file with this custom date (expiration date, mandatory law for fresh products).

    Could you help me on that please ?

    Thanks and regards

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author algol.plus

    (@algolplus)

    Hello

    You should use this way
    https://algolplus.freshdesk.com/support/solutions/articles/25000016635-add-calculated-field-for-order-

    Use $order->get_date_created() and add 5 days to it.

    Thanks, Alex

    Thread Starter LimingYun

    (@limingyun)

    Thanks Alex for your quick reply.

    Sorry, but I do not know how to add 5 days to the date.

    Could you please precise how to replace this part :
    $value = “text”;

    Thanks a lot !

    Plugin Author algol.plus

    (@algolplus)

    Thread Starter LimingYun

    (@limingyun)

    I write the whole PHP this way :

    add_filter(‘woe_get_order_value_custom_dlc_date’,function ($value, $order,$fieldname) {
    $value = “<?php echo $date_i18n( wc_date_format(), strtotime( $order->order_date ) + 30 * DAY_IN_SECONDS ); ?>”;
    return $value;
    },10,3);

    Does not work ??

    Plugin Author algol.plus

    (@algolplus)

    Try something like

    add_filter(‘woe_get_order_value_custom_dlc_date’,function ($value, $order,$fieldname) {
    $value = date_i18n( wc_date_format(), strtotime( $order->order_date ) + 5 * DAY_IN_SECONDS );
    return $value;
    },10,3);

    Thread Starter LimingYun

    (@limingyun)

    This last version of code you just sent seems valid, because no error (with “Enable debug output” option checked).

    But still not working. Here SQL details :

    SELECT ID AS order_id FROM bsk_posts AS orders LEFT JOIN bsk_postmeta AS ordermeta_cf_export_unmarked_orders ON ordermeta_cf_export_unmarked_orders.post_id = orders.ID AND ordermeta_cf_export_unmarked_orders.meta_key=’woe_order_exported’ WHERE orders.post_type in ( ‘shop_order’) AND 1 AND orders.post_status in (‘wc-processing’) AND orders.post_status NOT in (‘auto-draft’,’trash’) AND ( ordermeta_cf_export_unmarked_orders.meta_value IS NULL )

    Nota bene : the database has standard table prefix “wp_” replaced by “bsk_”

    Plugin Author algol.plus

    (@algolplus)

    Hello

    I’m in the hospital and has no access to computer. I can only suggest to hire programmer to debug this code.

    Thanks, Alex

    Thread Starter LimingYun

    (@limingyun)

    I am sorry for your situation ! Hope it is not too bad.

    Unfortunately, I have no finantial possibility to hire programmer.
    That’s too bad. The business for this website I am trying to launch is only for fresh food… Well, guess I have to abandon it.

    Anyway, thanks for your help.

    Plugin Author algol.plus

    (@algolplus)

    I used key “custom_dlc_date” , see updated code

    add_filter("woe_get_order_value_custom_dlc_date",function ($value, $order,$fieldname) {
    $value = date_i18n( wc_date_format(), strtotime( $order->order_date ) + 5 * DAY_IN_SECONDS );
    return $value;
    },10,3);
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Add custom date’ is closed to new replies.