@@ 172-174 (lines=3) @@ | ||
169 | $types = array_keys( wc_get_product_types() ); |
|
170 | $types[] = 'variation'; |
|
171 | ||
172 | if ( ! in_array( $data['type'], $types, true ) ) { |
|
173 | return new WP_Error( 'woocommerce_product_importer_invalid_type', __( 'Invalid product type.', 'woocommerce' ), array( 'status' => 401 ) ); |
|
174 | } |
|
175 | ||
176 | $classname = WC_Product_Factory::get_classname_from_product_type( $data['type'] ); |
|
177 | ||
@@ 186-196 (lines=11) @@ | ||
183 | } elseif ( ! empty( $data['id'] ) ) { |
|
184 | $product = wc_get_product( $id ); |
|
185 | ||
186 | if ( ! $product ) { |
|
187 | return new WP_Error( |
|
188 | 'woocommerce_product_csv_importer_invalid_id', |
|
189 | /* translators: %d: product ID */ |
|
190 | sprintf( __( 'Invalid product ID %d.', 'woocommerce' ), $id ), |
|
191 | array( |
|
192 | 'id' => $id, |
|
193 | 'status' => 401, |
|
194 | ) |
|
195 | ); |
|
196 | } |
|
197 | } else { |
|
198 | $product = new WC_Product_Simple( $id ); |
|
199 | } |
@@ 844-846 (lines=3) @@ | ||
841 | * @return array|bool Returns the tax class as an array. False if not found. |
|
842 | */ |
|
843 | public static function get_tax_class_by( $field, $item ) { |
|
844 | if ( ! in_array( $field, array( 'id', 'name', 'slug' ), true ) ) { |
|
845 | return new WP_Error( 'invalid_field', __( 'Invalid field', 'woocommerce' ) ); |
|
846 | } |
|
847 | ||
848 | if ( 'id' === $field ) { |
|
849 | $field = 'tax_rate_class_id'; |
|
@@ 882-884 (lines=3) @@ | ||
879 | public static function delete_tax_class_by( $field, $item ) { |
|
880 | global $wpdb; |
|
881 | ||
882 | if ( ! in_array( $field, array( 'id', 'name', 'slug' ), true ) ) { |
|
883 | return new WP_Error( 'invalid_field', __( 'Invalid field', 'woocommerce' ) ); |
|
884 | } |
|
885 | ||
886 | $tax_class = self::get_tax_class_by( $field, $item ); |
|
887 |
@@ 33-36 (lines=4) @@ | ||
30 | $errs[] = 'filesystem'; |
|
31 | } |
|
32 | ||
33 | if ( ! empty( $errs ) ) { |
|
34 | // translators: %s: Requirements unmet. |
|
35 | return new WP_Error( 'requirements_not_met', sprintf( __( 'Server requirements not met, missing requirement(s): %s.', 'woocommerce' ), implode( ', ', $errs ) ), array( 'status' => 400 ) ); |
|
36 | } |
|
37 | ||
38 | return true; |
|
39 | } |