WP の Shopp プラグインを使用しています。functions.php ファイルにカスタムの「メンバー価格」システムを書き込んでいますが、この価格を各アイテムの 1 つに制限する方法がわかりません。明確にするために、メンバーがアイテム A の数量 2 をカートに追加すると、そのうちの 1 つには特別価格が表示され、もう 1 つには正規価格が表示されます。ありがとうございました!
会員コードは以下の通りです。
/***********************
* SET PRICE BASED ON CLIENT TYPE
************************/
add_action('shopp_cart_add_item', 'my_function');
function my_function ( $Item ) {
global $Shopp, $current_user;
//only override price if we have a client type
if(count($_SESSION['userdata']->ClientTypes) > 0)
{
//check to see if there is a special price for this product
$prices = get_field('client_type_prices', $Item->product);
//reset for each prouct
$setspecial = FALSE;
$setprice = "";
foreach($prices as $price)
{
//get our client type unique id
$unique_id = get_field('unique_id', $price['client_type']->ID);
if(in_array($unique_id, $_SESSION['clienttypes']))
{
if(($price['price'] < $setprice) || ($setprice == "")){
$setprice = $price['price'];
$setspecial = TRUE;
}
}
}
//only actually override the price if a modified price has been entered for the item/type
if($setspecial)
{
$Item->unitprice = $setprice;
$Item->data->priced = $setprice;
}
}
return $Item;
}