Skip to content

Instantly share code, notes, and snippets.

@GeoffEW
Created June 15, 2016 16:47
Show Gist options
  • Save GeoffEW/ef196ef3154a747a851c771ae45fdecd to your computer and use it in GitHub Desktop.
Save GeoffEW/ef196ef3154a747a851c771ae45fdecd to your computer and use it in GitHub Desktop.
Updates _eventCost after updating price in WooCommerce
<?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' );
Copy link

ghost commented Mar 22, 2018

May i know where to put those line of codes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment