Check post type during read of coupons, posts, and products.
This commit is contained in:
parent
7d090957c8
commit
cddcb7841e
|
@ -82,7 +82,7 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
|
|||
public function read( &$order ) {
|
||||
$order->set_defaults();
|
||||
|
||||
if ( ! $order->get_id() || ! ( $post_object = get_post( $order->get_id() ) ) ) {
|
||||
if ( ! $order->get_id() || ! ( $post_object = get_post( $order->get_id() ) ) || 'shop_order' !== $post_object->post_type ) {
|
||||
throw new Exception( __( 'Invalid order.', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class WC_Coupon_Data_Store_CPT extends WC_Data_Store_WP implements WC_Coupon_Dat
|
|||
public function read( &$coupon ) {
|
||||
$coupon->set_defaults();
|
||||
|
||||
if ( ! $coupon->get_id() || ! ( $post_object = get_post( $coupon->get_id() ) ) ) {
|
||||
if ( ! $coupon->get_id() || ! ( $post_object = get_post( $coupon->get_id() ) ) || 'shop_coupon' !== $post_object->post_type ) {
|
||||
throw new Exception( __( 'Invalid coupon.', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
public function read( &$product ) {
|
||||
$product->set_defaults();
|
||||
|
||||
if ( ! $product->get_id() || ! ( $post_object = get_post( $product->get_id() ) ) ) {
|
||||
if ( ! $product->get_id() || ! ( $post_object = get_post( $product->get_id() ) ) || 'product' !== $post_object->post_type ) {
|
||||
throw new Exception( __( 'Invalid product.', 'woocommerce' ) );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue