関数
Validation::cartAllowsThisItem( int $post_id )
Checks for dlseller cart restrictions and returns a descriptive error if the item is not allowed to be added to cart
パラメータ パラメータ
- $post_id
(数値) (必須)
ファイル: src/API/Validation.php
public function cartAllowsThisItem($post_id) { global $usces; if (!defined('WCEX_DLSELLER')) { // don't worry about charge types if dlseller isn't active return true; } if (empty($usces->cart->num_row())) { return true; } $chargingtype = $usces->getItemChargingType($post_id); $chargingtype = !empty($chargingtype) ? strtolower($chargingtype) : ''; $carts = $usces->cart->get_cart(); $carts = !empty($carts) ? (array)$carts : []; // check if a continue charge type item already exists in cart $exists = false; foreach ($carts as $cart) { $cartitemct = $usces->getItemChargingType($cart['post_id']); $cartitemct = !empty($cartitemct) ? strtolower($cartitemct) : ''; if ($cartitemct === 'continue') { $exists = true; break; } } if ($exists === true) { if ($chargingtype === 'continue') { $emessage = __('You can add only one continuation charging item in your shopping cart.', 'dlseller'); return $this->master->estore->getErrorResponse( Store::CART_CONTAINS_CONTINUE_CHARGE, [$emessage], [$emessage] ); } $emessage = __('This is the continuation charging item. If you want to add this item, you have to clear your cart. Is it ok to clear your cart?', 'dlseller'); return $this->master->estore->getErrorResponse( Store::CART_CONTAINS_CONTINUE_CHARGE, [$emessage], [$emessage] ); } if ($chargingtype === 'continue') { $emessage = __( 'You have the continuation charging item in your shopping cart. If you want to add this item, you have to clear the item in your cart. Is it ok to clear your cart?', 'dlseller' ); return $this->master->estore->getErrorResponse( Store::CONTINUE_CHARGE_REQUIRES_EMPTY_CART, [$emessage], [$emessage] ); } return true; }