woocommerce-android icon indicating copy to clipboard operation
woocommerce-android copied to clipboard

Orders and Products Custom Fields

Open hafizrahman opened this issue 1 year ago • 7 comments

PT: pffQ75-If-p2

### UI Tasks
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12365
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12414
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12434
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12459
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12525
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12563
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12532
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12578
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12597
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12677
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12657
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12699
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12690
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12732
### Backend
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12212
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12356
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12357
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12696
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12752
### Miscellaneous
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12739
- [ ] https://github.com/woocommerce/woocommerce-android/issues/12748
- [ ] Remove feature flag and cleanup the code

hafizrahman avatar Aug 02 '24 12:08 hafizrahman

Thanks for reporting! 👍

dangermattic avatar Aug 02 '24 12:08 dangermattic

Hi @hafizrahman Sorry to jump in on your internal tracking, but I was wondering: might it be possible with this revision to introduce support for custom array fields? We have an array with information about a pick-up-point for the customer (location name, date, start & end time), and it currently doesn't show up when tapping the 'view custom fields' button in an order. Please let me know if I should create a separate issue instead. Kind regards

keunes avatar Aug 15 '24 05:08 keunes

@keunes, thank you for your message. We are confirming that the app will begin displaying more complex data types upon completion of this project. The data will be displayed as raw text, similar to how WordPress displays data in the "Custom Fields" section.

That being said, the app will continue to hide the keys that are not intended to be visible: keys that start with an underscore character _, this also aligns with what WordPress displays in the "Custom Fields" section.

hichamboushaba avatar Aug 15 '24 09:08 hichamboushaba

@keunes, upon further review of how the Custom Fields section operates in wp-admin, I discovered that it only lists literal values and does not show JSON values such as objects or arrays. Our project goal is to align the app with wp-admin's behavior, so my previous response was inaccurate, and I apologize for the confusion.

Can you provide more details about your use case so that I can give you a more accurate answer than my previous comment? Please share the following with us:

  1. How is the field being added to the order? Is it done manually or using a plugin?
  2. An example of the field's content would be great.
  3. Do you intend to edit the field's content on the mobile app, or do you just want it to be displayed?

hichamboushaba avatar Aug 16 '24 11:08 hichamboushaba

Hi @hichamboushaba,

Ah, I see. To answer your questions:

How is the field being added to the order? Is it done manually or using a plugin?

It's done using a plug-in we wrote ourselves (which I hope to open source later). Here's the code:

function LCLPC_save_pup_details($order_id) {
    if (!isset($_POST['LCLPC_pup'])) { return; }

    $pup = json_decode(stripslashes($_POST['LCLPC_pup']), true);

    // Save the array in the post meta
    update_post_meta($order_id, 'LCLPC_pup', $pup);
}
add_action('woocommerce_checkout_update_order_meta', 'LCLPC_save_pup_details');

and in front-end (during check-out):

<input type="radio" <?= $next_date['available'] ? '' : 'disabled'; ?> name="LCLPC_pup" value='<?= htmlspecialchars(json_encode([
							'slug' => $slug,
							'date' => $next_date['date'],
							'open' => $next_date['open'],
							'close' => $next_date['close']
						]), ENT_QUOTES, 'UTF-8') ?>' <?php if ($k == 0 && $next_date['available']) { echo ' checked'; $k++; } ?>>

An example of the field's content would be great.

Here's what it looks like when viewing/editing an order:

Do you intend to edit the field's content on the mobile app, or do you just want it to be displayed?

Having the ability to edit would be nice, but being able to view the information would already be a huge help.

As you may see from above, we work with pick-up points (PUPs) that the user selects during check-out. We go to these PUPs by bike. We currently have to log in to our back-end to see when & where we need to go for the order. If we can see that info directly in the app, it would be an enormous help in planning our day / bike trip.

So for us it would be cool if you'd go for 'feature parity+' ;-)

keunes avatar Aug 20 '24 20:08 keunes

Thanks @keunes for the information, as suspected, this would fall outside of the initial scope of our project, since we were aiming to just support what the "Custom Fields" section in the backend (wp-admin) supports, and it won't show the value of the meta LCLPC_pup in your case, since it contains a JSON array.

We'll discuss this internally and see if we can increase the scope of the project, I'll update the ticket when we find out more.

hichamboushaba avatar Aug 22 '24 17:08 hichamboushaba

Hey @keunes, sorry for the late reply, just wanted to share that we agreed on adding support for reading JSON values to the feature, and it will be available when we ship it, you can check how it will look here, if you have any remarks please feel free to share them. Thanks again.

hichamboushaba avatar Oct 01 '24 10:10 hichamboushaba