added hooks to support analytics plugins

successful ajax add to cart : woocommerce_ajax_added_to_cart,
$product_id

added valid coupon: woocommerce_applied_coupon, $coupon_code

reorded : woocommerce_ordered_again, $order->id

tracked order : woocommerce_track_order, $order->id

calculated shipping on cart : woocommerce_calculated_shipping
This commit is contained in:
Max Rice 2012-08-05 12:42:25 -04:00
parent c7c247b6dc
commit e9a75830c8
5 changed files with 11 additions and 1 deletions

View File

@ -1593,6 +1593,9 @@ class WC_Cart {
$this->set_session();
$woocommerce->add_message( __('Discount code applied successfully.', 'woocommerce') );
do_action( 'woocommerce_applied_coupon ', $coupon_code );
return true;
} else {

View File

@ -67,6 +67,8 @@ function woocommerce_cart( $atts ) {
$woocommerce->add_message( __('Shipping costs updated.', 'woocommerce') );
endif;
do_action( 'woocommerce_calculated_shipping' );
}

View File

@ -45,7 +45,7 @@ function woocommerce_order_tracking( $atts ) {
if ( $order->id && $order_email ) {
if ( strtolower( $order->billing_email ) == strtolower( $order_email ) ) {
do_action( 'woocommerce_track_order', $order->id );
woocommerce_get_template( 'order/tracking.php', array(
'order' => $order
) );

View File

@ -174,6 +174,7 @@ function woocommerce_ajax_add_to_cart() {
if ($passed_validation && $woocommerce->cart->add_to_cart($product_id, 1)) :
// Return html fragments
$data = apply_filters('add_to_cart_fragments', array());
do_action( 'woocommerce_ajax_added_to_cart', $product_id);
else :
// If there was an error adding to the cart, redirect to the product page to show any errors
$data = array(

View File

@ -658,6 +658,8 @@ function woocommerce_order_again() {
$woocommerce->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations );
}
do_action( 'woocommerce_ordered_again', $order->id );
// Redirect to cart
$woocommerce->add_message( __('The cart has been filled with the items from your previous order.', 'woocommerce' ) );
@ -686,6 +688,8 @@ function woocommerce_cancel_order() {
// Message
$woocommerce->add_message( __('Your order was cancelled.', 'woocommerce') );
do_action( 'woocommerce_cancelled_order', $order->id );
elseif ($order->status!='pending') :