Stephen S
Forum Replies Created
-
Ok, I realized that my error logging for the second one should have been in the trigger function, and once I put it there, it did indeed verify that the order was correct. Now to figure out why the meta data that I added in the first is not being added to the email, despite existing in the db….
Well, after a little digging, I have discovered that my function is NOT running first. I added error logging after each of those and found that the built-in woocommerce action (woocommerce/includes/emails/class-wc-email-customer-completed-order.php) is indeed running before the one in my functions.php, EVEN though the built in one is:
add_action( 'woocommerce_order_status_completed_notification', array( $this, 'trigger' ) );and mine is:
add_action( 'woocommerce_order_status_completed_notification', 'mysite_woocommerce_order_status_completed', 5 );So, any idea why that might happen? I am loathe to add a priority to or change the base code…
also tried
wc_get_order_item_meta( $item_id, 'signup_code' );instead of
update_meta_cache( 'CHAR', $signupkey );but to no avail either. 🙁
Thanks for the feedback, I am looking in that direction now, although updata_meta_cache either isn’t working or I am using it incorrectly. For what it is worth, my code looks like this:
function mysite_woocommerce_order_status_completed( $order_id ) { $wooitems = new WC_Order( $order_id ); $woouser_id = $wooitems->user_id; $_wooitems = $wooitems->get_items(); foreach ($_wooitems as $item_id => $product) { $randomcode = substr(rtrim(base64_encode(md5(microtime())),"="), 0, -20); $signupkey = 'signup_code'; wc_add_order_item_meta( $item_id, $signupkey, $randomcode, true ); if ($woouser_id) { $signupcodeused = wc_get_order_item_meta($item_id,$signupkey, true); update_user_meta( $woouser_id, 'signup_code', $signupcodeused ); } update_meta_cache( 'CHAR', $signupkey ); //NEW, trying several variations, none work so far } }I am having an issue trying to implement something similar. I have code that runs and inserts metadata, and I want it to run just BEFORE order completed email goes out, so that the meta data will be included in the email. But when I call:
add_action( 'woocommerce_order_status_completed_notification','mysite_woocommerce_order_status_completed',5 );Although it has a lower priority, it still seems to run AFTER the email goes out, instead of before as I intended. If I “recomplete” the order (putting it back into processing status and then completed again), it will send the meta data (although this is because it is now already in the db)
Any ideas for why my hook isn’t running BEFORE the email? Thanks in advance for any help!
Forum: Plugins
In reply to: [SlimStat Analytics] "Unexpected output" after updating to 4.3.2same problem here! I reverted back to the previous version which has fixed this for now.
Forum: Plugins
In reply to: [Better Admin Pointers] Can a chain of pointers be created?Sorry, off the top of my head, I don’t. But search the plugin repo, there is probably something that fits the bill.
Forum: Plugins
In reply to: [Better Admin Pointers] Can a chain of pointers be created?Hi, thanks for the feedback. This has been a requested feature before, and I am definitely considering it, though it is not an insignificant amount of work that I will need to slot in between my paid gigs.
Forum: Plugins
In reply to: [Better Admin Help Tabs] Paragraphs & Line BreaksFixed in version 1.3. Thanks for the heads up.
Forum: Plugins
In reply to: [Better Admin Help Tabs] Compatibility issueJust found the cause and fixed this in version 1.3. Thanks for the heads up.
Forum: Plugins
In reply to: [Better Admin Pointers] How to use in the customizerSorry but the customizer has no screen (page title) as most other pages in the admin have, so it is not possible to add pointers to it (at least not using my plugin).
Sorry there is no way around this that would not respect the fact that the page (and all content on it, including pointers) is meant to be private.
Forum: Plugins
In reply to: [Better Admin Pointers] Yes, Network capability existsThanks for the investigation!
Forum: Plugins
In reply to: [Better Admin Pointers] Swedish translationThanks, can you please reissue the links? These are not working for me and I will include them in the next version.
Forum: Plugins
In reply to: [WP Geo] pages with multiple posts stopped working if paged?nevermind, I figured this out myself. Here is new code which works. Hopefully it will help someone else out:
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $offsetnum = (($paged*10)-10); wpgeo_map( array( 'offset' => $offsetnum, 'posts_per_page' =>10 ) );