jetformbuilder
/
includes
/
compatibility
/
woocommerce
/
methods
/
wc-product-modification
/
product-id-property.php
jetformbuilder
/
includes
/
compatibility
/
woocommerce
/
methods
/
wc-product-modification
Last commit date
base-product-property.php
3 years ago
product-backorders-property.php
3 years ago
product-catalog-visibility-property.php
3 years ago
product-cross-sell-ids-property.php
3 years ago
product-date-on-sale-from-property.php
3 years ago
product-date-on-sale-to-property.php
3 years ago
product-date-property.php
3 years ago
product-description-property.php
3 years ago
product-featured-property.php
3 years ago
product-gallery-property.php
3 years ago
product-height-property.php
3 years ago
product-id-property.php
3 years ago
product-image-property.php
3 years ago
product-length-property.php
3 years ago
product-low-stock-amount-property.php
3 years ago
product-manage-stock-property.php
3 years ago
product-name-property.php
3 years ago
product-parent-property.php
3 years ago
product-regular-price-property.php
3 years ago
product-reviews-allowed-property.php
3 years ago
product-sale-price-property.php
3 years ago
product-short-description-property.php
3 years ago
product-sku-property.php
3 years ago
product-sold-individually-property.php
3 years ago
product-status-property.php
3 years ago
product-stock-quantity-property.php
3 years ago
product-stock-status-property.php
3 years ago
product-tax-class-property.php
3 years ago
product-tax-status-property.php
3 years ago
product-total-sales-property.php
3 years ago
product-upsell-ids-property.php
3 years ago
product-weight-property.php
3 years ago
product-width-property.php
3 years ago
save-action.php
3 years ago
trash-action.php
3 years ago
wc-product-modifier.php
3 years ago
product-id-property.php
41 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Compatibility\Woocommerce\Methods\Wc_Product_Modification; |
| 5 | |
| 6 | |
| 7 | use Jet_Form_Builder\Actions\Methods\Abstract_Modifier; |
| 8 | use Jet_Form_Builder\Actions\Methods\Object_Required_Property; |
| 9 | use Jet_Form_Builder\Actions\Methods\Post_Modification\Post_Id_Property; |
| 10 | use Jet_Form_Builder\Actions\Methods\Post_Modification\Post_Modifier; |
| 11 | use Jet_Form_Builder\Exceptions\Action_Exception; |
| 12 | use Jet_Form_Builder\Exceptions\Silence_Exception; |
| 13 | |
| 14 | class Product_Id_Property extends Post_Id_Property { |
| 15 | |
| 16 | /** |
| 17 | * @param string $key |
| 18 | * @param $value |
| 19 | * @param Abstract_Modifier $modifier |
| 20 | * |
| 21 | * @throws Action_Exception |
| 22 | */ |
| 23 | public function do_before( string $key, $value, Abstract_Modifier $modifier ) { |
| 24 | try { |
| 25 | $this->value = new \WC_Product( $value ); |
| 26 | } catch ( \Exception $exception ) { |
| 27 | throw new Action_Exception( $exception->getMessage() ); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | public function get_product(): \WC_Product { |
| 32 | if ( is_a( $this->value, \WC_Product::class ) ) { |
| 33 | return $this->value; |
| 34 | } |
| 35 | $this->value = new \WC_Product_Simple(); |
| 36 | |
| 37 | return $this->value; |
| 38 | } |
| 39 | |
| 40 | |
| 41 | } |