WPIntell

Source evidence

Add event name

Pushover Integration for WooCommerce · support · 2020-07-14T12:38:00+00:00

mixedsentiment
mediumseverity
0.84relevance
7replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

10 / 67 rows with source links

14.9% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

57 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
puntorosso resolved
Hi, we use WooCommerce together with the plugin Tickera to sell concert tickets. The product names (ticket categories) are almost the same for every concert (like “General”, “VIP” etc., so when we receive the push notification we don’t know from which event they are. Tickera cannot affect the title of WooCommerce products. However, it does store the event ID as product post meta and it is stored to the database with _event_name meta key. Wouldn’t be possible to add at least a shortcode for the “note” field or the category? This way we could use these fields to identify the related concert. Thanks This topic was modified 5 years, 10 months ago by puntorosso . hello @puntorosso , Thanks for the detailed question. Are you familiar with using WordPress filters ? There is a filter in the notify_new_order() method that can be used to modify the Title or the Message before the notification is sent. I will need to add $order_id to the $args array so you can pull the _event_name meta. How does that sound? Sounds great! Thank you very much for your prompt response I have contacted the Tickera’s developers and they suggested that, in order to add the event title on the product name, your plugin should have a hook that forward the product ID. They would use then this hook to query the event ID and then, based on that, the event title. ​Thanks I will deploy version 1.0.18 today and it will have the $order_id in the hook. Here is a gist that will add product meta to the notification: https://gist.github.com/growdev/03a5dbeca1a436165a7cc214075c94ad <?php /** * Hook into Pushover send notification on new order and add something to the title from order. * * @hook 'wc_pushover_notify_new_order' * @param $args * @return mixed */ function sp_wc_pushover_notify_new_order( $args ) { if ( isset( $args['order_id'] ) ) { $order_id = $args['order_id']; $meta = get_post_meta( $order_id, '_billing_country', true ); if ( $meta ) { // Add to title $args['title'] .= ' Country is ' . $meta; // Modify the message //$args['message'] = ''; // Modify the URL //$args['url'] = ''; } } return $args; } add_filter( 'wc_pushover_notify_new_order', 'sp_wc_pushover_notify_new_order', 10 ); Perfect! A great solution. Thanks a lot for your help. Best You’re welcome. Version 1.0.18 is now available. The Tickera’s developers integrated your plugin using this snippet and it works perfectly. Thanks again for your help. Best function tc_event_title_pushover( $args ) { if ( isset( $args['order_id'] ) ) { $order_id = $args['order_id']; $order = wc_get_order( $order_id ); $items = $order->get_items(); foreach ( $items as $item ) { $product_id = $item->get_product_id(); $event_id = get_post_meta($product_id, '_event_name', true); $event_title = get_the_title($event_id); } if ( $item ) { $args['title'] .= ' for '.$event_title; } } return $args; } add_filter( 'wc_pushover_notify_new_order', 'tc_event_title_pushover', 10 ); This reply was modified 5 years, 10 months ago by puntorosso . This reply was modified 5 years, 10 months ago by puntorosso .

Comments

7 shown
Daniel Espinoza 2020-07-14T15:11:00+00:00

hello @puntorosso , Thanks for the detailed question. Are you familiar with using WordPress filters ? There is a filter in the notify_new_order() method that can be used to modify the Title or the Message before the notification is sent. I will need to add $order_id to the $args array so you can pull the _event_name meta. How does that sound?

puntorosso 2020-07-14T15:13:00+00:00

Sounds great! Thank you very much for your prompt response

puntorosso 2020-07-14T18:13:00+00:00

I have contacted the Tickera’s developers and they suggested that, in order to add the event title on the product name, your plugin should have a hook that forward the product ID. They would use then this hook to query the event ID and then, based on that, the event title. ​Thanks

Daniel Espinoza 2020-07-14T18:19:00+00:00

I will deploy version 1.0.18 today and it will have the $order_id in the hook. Here is a gist that will add product meta to the notification: https://gist.github.com/growdev/03a5dbeca1a436165a7cc214075c94ad <?php /** * Hook into Pushover send notification on new order and add something to the title from order. * * @hook 'wc_pushover_notify_new_order' * @param $args * @return mixed */ function sp_wc_pushover_notify_new_order( $args ) { if ( isset( $args['order_id'] ) ) { $order_id = $args['order_id']; $meta = get_post_meta( $order_id, '_billing_country', true ); if ( $meta ) { // Add to title $args['title'] .= ' Country is ' . $meta; // Modify the message //$args['message'] = ''; // Modify the URL //$args['url'] = ''; } } return $args; } add_filter( 'wc_pushover_notify_new_order', 'sp_wc_pushover_notify_new_order', 10 );

puntorosso 2020-07-14T19:05:00+00:00

Perfect! A great solution. Thanks a lot for your help. Best

Daniel Espinoza 2020-07-15T12:27:00+00:00

You’re welcome. Version 1.0.18 is now available.

puntorosso 2020-07-20T16:26:00+00:00

The Tickera’s developers integrated your plugin using this snippet and it works perfectly. Thanks again for your help. Best function tc_event_title_pushover( $args ) { if ( isset( $args['order_id'] ) ) { $order_id = $args['order_id']; $order = wc_get_order( $order_id ); $items = $order->get_items(); foreach ( $items as $item ) { $product_id = $item->get_product_id(); $event_id = get_post_meta($product_id, '_event_name', true); $event_title = get_the_title($event_id); } if ( $item ) { $args['title'] .= ' for '.$event_title; } } return $args; } add_filter( 'wc_pushover_notify_new_order', 'tc_event_title_pushover', 10 ); This reply was modified 5 years, 10 months ago by puntorosso . This reply was modified 5 years, 10 months ago by puntorosso .