Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions woocommerce-sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ function filter_session($cart_content, $value, $key){
if ($value['sample']){
$cart_content['sample'] = true;
$cart_content['unique_key'] = $value['unique_key'];
//$cart_content['data']->price = 0;
//$cart_content['data']->set_price( '0' );
$product_id = $cart_content['product_id'];
$sample_price_mode = get_post_meta($product_id, 'sample_price_mode', true) ? get_post_meta($product_id, 'sample_price_mode', true) : 'default';
$sample_price = get_post_meta($product_id, 'sample_price', true) ? get_post_meta($product_id, 'sample_price', true) : 0;
if ($sample_price_mode === 'custom'){
$cart_content['data']->price = $sample_price;
$cart_content['data']->set_price( $sample_price );
}else if ($sample_price_mode === 'free'){
$cart_content['data']->price = 0;
$cart_content['data']->set_price( '0' );
}else{
//default
}
Expand All @@ -232,7 +232,7 @@ function add_sample_to_cart_item_data ($cart_item_data, $product_id, $variation_

function add_sample_to_cart_item ($cart_item, $cart_item_key){
if ($cart_item['sample'] === true){
$cart_item['data']->price = 0;
$cart_item['data']->set_price( '0' );
}
return $cart_item;
}
Expand Down