Created
June 15, 2016 16:47
-
-
Save GeoffEW/ef196ef3154a747a851c771ae45fdecd to your computer and use it in GitHub Desktop.
Updates _eventCost after updating price in WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* If a (ticket) product is updated via the WooCommerce product editor | |
* or even via quick edits then attempt to keep the cost fields in sync. | |
* | |
* @param int $product_id | |
*/ | |
function tempfix_62004_sync_ticket_price( $product_id ) { | |
if ( ! class_exists( 'Tribe__Tickets_Plus__Commerce__WooCommerce__Main' ) ) return; | |
if ( ! tribe_events_product_is_ticket( $product_id ) ) return; | |
$woo_provider = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance(); | |
$event = $woo_provider->get_event_for_ticket( $product_id ); | |
if ( ! $event ) return; | |
Tribe__Events__API::saveEventMeta( $event->ID, array() ); | |
} | |
add_action( 'woocommerce_product_quick_edit_save', 'tempfix_62004_sync_ticket_price' ); | |
add_action( 'woocommerce_process_product_meta_simple', 'tempfix_62004_sync_ticket_price' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
May i know where to put those line of codes?