関数
Validation::itemExists( int $post_id, string $sku = '' )
GenericError instance if the item has been deleted or put in the ‘trash’, true otherwiseパラメータ パラメータ
- $post_id
(数値) (必須)
- $sku
(文字列) (任意) Optional. This is only used for error message construction.
ファイル: src/API/Validation.php
public function itemExists($post_id, $sku = '') {
global $wpdb;
$p = get_post($post_id);
if ($p === null) {
return $this->master->estore->getErrorResponse(Store::ITEM_DELETED, [$post_id], [$sku]);
}
$pstatus = $wpdb->get_var($wpdb->prepare("SELECT post_status FROM {$wpdb->posts} WHERE ID = %d", $post_id));
if ($pstatus === 'trash') {
return $this->master->estore->getErrorResponse(Store::POST_IN_TRASH, [$post_id], [$sku]);
}
return true;
}