$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $_POST['product_id'] ) );
$quantity = empty( $_POST['quantity'] ) ? 1 : wc_stock_amount( $_POST['quantity'] );
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity );
- $product_status = get_post_status( $product_id );
+// $product_status = get_post_status( $product_id );
+ $product_status = get_post_status($product_id, 'product'); // データタイプを指定
if ( $passed_validation && false !== WC()->cart->add_to_cart( $product_id, $quantity ) && 'publish' === $product_status ) {
-
do_action( 'woocommerce_ajax_added_to_cart', $product_id );
if ( get_option( 'woocommerce_cart_redirect_after_add' ) == 'yes' ) {
* @param int $status_code The HTTP status code to output.
*/
function wp_send_json( $response, $status_code = null ) {
+ global $gPageManager;
+
+ // システムを中断
+ $gPageManager->abortPage();
+
@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
if ( null !== $status_code ) {
status_header( $status_code );
}
echo wp_json_encode( $response );
- if ( wp_doing_ajax() ) {
+ // システム終了
+ $gPageManager->exitSystem();
+
+/* if ( wp_doing_ajax() ) {
wp_die( '', '', array(
'response' => null,
) );
} else {
die;
- }
+ }*/
}
/**
* @return bool True if it's a WordPress Ajax request, false otherwise.
*/
function wp_doing_ajax() {
+ // AJAX起動かどうかは$_GET['wc-ajax']の値があるかどうかで判断される
/**
* Filters whether the current request is a WordPress Ajax request.
*