Action: tcp add shopping cart

Description

The “tcp_add_shopping_cart” action is used to execute custom code after filling the shopping cart.

Parameters

$post_ids
(Array) Post ids list added to the shopping cart.

Example

<?php
//this function stores the number of times a product has been added to shopping cart (statistics purpose?)
function count_adding( $post_ids ) {
	foreach( $post_ids as $post_id ) {
		$n = get_post_meta( $post_id, 'n_adding_cart', true );
		if ( $n === '' ) $n = 0;
		update_option( $post_id, 'n_adding_cart', $n++ );
	}
}
add_filter( 'tcp_add_shopping_cart', 'count_adding' ); ?>

Change Log

Since 1.0.8