I'm trying to build a custom form using UserFrontend on wordpress and I need to copy an array from one of the known meta keys from WooCommerce. Only thing is I'm not sure how to approach this issue as each field only returns one value. What I really need is to for the user to enter in a date range and translate into part of an array for this meta key value.

I've tried creating custom field groups but they don't show up in UserFrontend

this is the field that can be access in the admin backend: Date range picker in WooCommerce

this is what I need it too look like...

_wc_booking_availability (this is the meta key)

This is the returned value:

array (
  0 => 
  array (
    0 => 
    array (
      'type' => 'custom',
      'bookable' => 'yes',
      'priority' => 10,
      'from' => '2019-05-13', //this was set using a date picker
      'to' => '2019-05-27',
  • I'd advise against storing serialised structured data in post meta keys. If you ever need to query for those values you'll be in for a world of pain that will need you to destructure into multiple post meta fields undoing your work to get it working. You also open yourself up to PHP object deserialisation exploits so there are security consequences of doing this. I strongly advise against it – Tom J Nowell May 14 at 13:30
  • I see what you mean. but this was the default value that woocommerce makes. If I were to create a booking product on the backend this was the array that was returned. I simply used a post meta reader to see what values each meta key was returning when I created a product through their creator. What I simply want to do is recreate it using my own fields. Im not sure how else I can get the same functionality in the product page without this meta key value. – aangel10 May 14 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.