base-product-property.php
2 years ago
product-backorders-property.php
2 years ago
product-catalog-visibility-property.php
2 years ago
product-cross-sell-ids-property.php
2 years ago
product-date-on-sale-from-property.php
2 years ago
product-date-on-sale-to-property.php
2 years ago
product-date-property.php
1 year ago
product-description-property.php
1 year ago
product-featured-property.php
2 years ago
product-gallery-property.php
2 years ago
product-height-property.php
2 years ago
product-id-property.php
1 year ago
product-image-property.php
1 year ago
product-length-property.php
2 years ago
product-low-stock-amount-property.php
1 year ago
product-manage-stock-property.php
1 year ago
product-name-property.php
1 year ago
product-parent-property.php
1 year ago
product-regular-price-property.php
2 years ago
product-reviews-allowed-property.php
1 year ago
product-sale-price-property.php
2 years ago
product-short-description-property.php
1 year ago
product-sku-property.php
2 years ago
product-sold-individually-property.php
1 year ago
product-status-property.php
1 year ago
product-stock-quantity-property.php
1 year ago
product-stock-status-property.php
1 year ago
product-tax-class-property.php
1 year ago
product-tax-status-property.php
1 year ago
product-total-sales-property.php
1 year ago
product-upsell-ids-property.php
2 years ago
product-weight-property.php
2 years ago
product-width-property.php
2 years ago
save-action.php
1 year ago
trash-action.php
1 year ago
wc-product-modifier.php
1 year ago
save-action.php
58 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace JFB_Compatibility\Woocommerce\Methods\Wc_Product_Modification; |
| 5 | |
| 6 | use Jet_Form_Builder\Actions\Methods\Abstract_Modifier; |
| 7 | use JFB_Modules\Actions_V2\Insert_Post\Properties\Base_Post_Action; |
| 8 | use JFB_Modules\Actions_V2\Insert_Post\Insert_Post_Action; |
| 9 | |
| 10 | // If this file is called directly, abort. |
| 11 | if ( ! defined( 'WPINC' ) ) { |
| 12 | die; |
| 13 | } |
| 14 | |
| 15 | class Save_Action extends Base_Post_Action { |
| 16 | |
| 17 | public function get_id(): string { |
| 18 | return 'insert'; |
| 19 | } |
| 20 | |
| 21 | public function do_action() { |
| 22 | if ( ! $this->pre_check() ) { |
| 23 | return; |
| 24 | } |
| 25 | /** @var Product_Id_Property $id */ |
| 26 | $id = $this->modifier->get( 'ID' ); |
| 27 | |
| 28 | $this->inserted_id = $id->get_product()->save(); |
| 29 | } |
| 30 | |
| 31 | public function add_context_once() { |
| 32 | if ( ! jet_fb_action_handler()->in_loop() ) { |
| 33 | return; |
| 34 | } |
| 35 | /** @var Product_Id_Property $id */ |
| 36 | $id = $this->modifier->get( 'ID' ); |
| 37 | $product = $id->get_product(); |
| 38 | |
| 39 | /** |
| 40 | * For Redirect to Page action |
| 41 | */ |
| 42 | jet_fb_action_handler()->add_context_once( |
| 43 | 'insert_post', |
| 44 | array( |
| 45 | Insert_Post_Action::get_context_post_key( $this->inserted_id ) => array( |
| 46 | '__action' => $this->get_id(), |
| 47 | 'ID' => $this->inserted_id, |
| 48 | 'post_status' => $product->get_status(), |
| 49 | ), |
| 50 | ) |
| 51 | ); |
| 52 | } |
| 53 | |
| 54 | public static function is_supported( Abstract_Modifier $modifier ): bool { |
| 55 | return true; |
| 56 | } |
| 57 | } |
| 58 |