daymobrew
Forum Replies Created
-
So as not to override cmb2 2.10.1 I put the
developbranch version inwp-content/plugins/CMB2-developdirectory.My cmb2 code has not changes – still https://pastebin.com/PDFBNgaQ
I downloaded the zip from github.
developbranch has version number 2.10.0.For hpos add-on I downloaded the zip from github and activated that as a plugin. I’ve been trying to debug in VSC but my breakpoints are ‘unverified’ and ignored so I just began adding error_log() calls to verify the code is being run. The
CMB2_Woo_HPOS_Orders::_constructfunction. I then added error_log() to init_hooks but that did not run. I could find thedo_action( 'cmb2_init_hooks' )call anywhere in CMB2 2.10.1 or CMB2 develop. Similar issue for the add_filter() calls tocmb2_set_box_object_typeandcmb2_set_box_object_type– cannot find the matching apply_filters() calls.- This reply was modified 2 years, 8 months ago by daymobrew. Reason: Add info about add_filter
Justin – thank you for all that work.
I have replaced CMB2 with CMB2-develop and added cmb2-woocommerce-hpos-orders plugin.
The meta box shows and the CSS is enqueued.
The submitted values do not show when I Update the order. Nor is the data written to the
wp_wc_orders_metadb table.I am happy to debug here – just let me know what areas I should look at.
- This reply was modified 2 years, 8 months ago by daymobrew. Reason: Mention that values not in db
Code: https://pastebin.com/PDFBNgaQ
To set up HPOS in WooCommerce: https://woocommerce.com/document/high-performance-order-storage/#section-2
Essentially: WooCommerce/Settings/Advanced/Features then click ‘High performance order storage (new)’. I also uncheck ‘Keep the posts and orders tables in sync (compatibility mode).’
I can see that ‘
cmb2_override_meta_value‘ is not being run because inCMB2_Field::__construct()$args[‘object_id’] is zero so $this->object_id is zero and$this->get_data()does not get called.If my field group has object_type=page then object_id will be the page ID.
- This reply was modified 2 years, 8 months ago by daymobrew. Reason: Typo in filter name
Yes, still an issue.
CMB2_Hookup::save_post()andCMB2_Hookup::can_save()are being run on save but not the ‘cmb2_override_meta_save‘ filter ascan_save()returnsfalse.I have the following filters running successfully:
// To read from custom table.add_filter( 'cmb2_override_meta_value', 'dcwd_cmb2_override_meta_value', 10, 4 );// To get past can_save() checks. Returns true when my 2 fields are in $_POST.add_filter( 'cmb2_can_save', 'dcwd_cmb2_can_save', 10, 2 );but my ‘
cmb2_override_meta_save‘ filter is not running. I also have ‘cmb2_override_tracking_number_meta_save‘ and ‘cmb2_override_tracking_url_meta_save‘ (to match field IDs) but they don’t run either.Partial code: https://pastebin.com/sEQr7Rcu
- This reply was modified 2 years, 8 months ago by daymobrew. Reason: Make code comments easier to read
Forum: Plugins
In reply to: [CMB2] How do I show metabox on WooCommerce Order page for HPOS setupThe PR has been merged into the CMB2 develop branch so closing this thread.
Forum: Plugins
In reply to: [CMB2] How do I show metabox on WooCommerce Order page for HPOS setupIs this better? (I have a feeling it isn’t).
https://github.com/CMB2/CMB2/pull/1495
If not then I’ll submit as a GitHub Issue.
Forum: Plugins
In reply to: [CMB2] How do I show metabox on WooCommerce Order page for HPOS setupOk, I’ll try that tomorrow. I used GitHub web interface and it made me fork it.
I’ve been going through the includes/CMB2_Hookup.php code. I can see that
save_post()is not being called. Looking through the WooCommerce code maybe ‘woocommerce_process_shop_order_meta’ needs to be hooked to.add_action( 'woocommerce_process_shop_order_meta', array( $this, 'save_post' ), 10, 2 );Adding this helps a lot!
can_save()gets run though$typeis not set so it fails. It’s not set becausesave_post()cannot determine the post type.I could use the ‘
cmb2_can_save‘ filter to override can_save()’s false result but that seems risky.Forum: Plugins
In reply to: [CMB2] How do I show metabox on WooCommerce Order page for HPOS setupThe CMB2 styles are not being loaded so the text field max-width is not set to 100% (it says as
.regular-text { width: 25em; })I created a pull request to load CMB2 styles on the WooCommerce Edit Order page when HPOS enabled: https://github.com/damiencarbery/CMB2/pull/1
Forum: Plugins
In reply to: [CMB2] How do I show metabox on WooCommerce Order page for HPOS setupI experimented a bit and found that
get_current_screen()->id == 'woocommerce_page_wc-orders'so the metabox now shows.I’ll experiment a bit more before marking this as resolved.
Brilliant, thank you. I should have looked around the page better.
Forum: Plugins
In reply to: [Meta for WooCommerce] UPDATE BREAKS ADMIN PRODUCT SEARCHSame issue for me.
Urls are getting multiple #038; added to them. Some still work, other actions redirect to posts page as other are experiencing.