wpsc_update_variation_product

Located in: ajax.function.php

Functions that call this hook: wpsc_update_product_price()
Arguments Accepted: $product_id, $variations
Version Introduced: 3.8

Description: This hook is called every time a new variation is selected from the product page, the function wpsc_update_product_price() is used to return the updated price of a variation – this hook is triggered before the new price information is generated and returned.

Code in context:
[php firstline=”402″ highlight=”423″]
/**
* update_product_page_price function, used through ajax with variations
* No parameters, returns nothing
*/
function wpsc_update_product_price() {
global $wpdb, $wpsc_cart;
$from = ”;
$change_price = true;
$product_id = (int) $_POST[‘product_id’];
$variations = array();
$response = array(
‘product_id’ => $product_id,
‘variation_found’ => false,
);
if ( ! empty( $_POST[‘variation’] ) ) {
foreach ( $_POST[‘variation’] as $variation ) {
if ( is_numeric( $variation ) ) {
$variations[] = (int)$variation;
}
}

do_action( ‘wpsc_update_variation_product’, $product_id, $variations );

$stock = wpsc_check_variation_stock_availability( $product_id, $variations );

if ( $stock !== false ) {
$response[‘variation_found’] = true;
if ( $stock === 0 ) {
$response += array(
‘product_msg’ => __( ‘Sorry, but this variation is out of stock.’, ‘wpsc’ ),
‘variation_msg’ => __( ‘Variation not in stock’, ‘wpsc’ ),
‘stock_available’ => false,
);
} else {
$response += array(
‘variation_msg’ => __( ‘Product in stock’, ‘wpsc’ ),
‘stock_available’ => true,
);
}

if ( $change_price ) {
[/php]