| @@ -34,9 +34,9 @@ | ||
| 34 | 34 | * |
| 35 | 35 | * @return int|void |
| 36 | 36 | */ |
| 37 | 37 | public static function check_version() { |
| 38 | - $version = ExtraSettings::instance()->get_option( 'rtsb_version', '' ) ?? get_option( 'rtsb_version' ); | |
| 38 | + $version = ExtraSettings::instance()->get_option( 'rtsb_version' ) ?? get_option( 'rtsb_version' ); | |
| 39 | 39 | if ( version_compare( $version, RTSB_VERSION, '<' ) ) { |
| 40 | 40 | if ( ! $version ) { |
| 41 | 41 | self::set_default_options(); |
| 42 | 42 | if ( ! Fns::get_product() ) { |
| @@ -90,25 +90,11 @@ | ||
| 90 | 90 | * @return void |
| 91 | 91 | */ |
| 92 | 92 | public static function deactivation() { |
| 93 | 93 | delete_option( 'shopbuilder_permalinks_flushed' ); |
| 94 | - self::clear_scheduled_events(); | |
| 95 | 94 | } |
| 95 | + | |
| 96 | 96 | /** |
| 97 | - * Clear Scheduled Events | |
| 98 | - * | |
| 99 | - * @return void | |
| 100 | - */ | |
| 101 | - public static function clear_scheduled_events() { | |
| 102 | - $schedule = get_option( 'rtsb_cron_schedule_free', [] ); | |
| 103 | - if ( empty( $schedule ) ) { | |
| 104 | - return; | |
| 105 | - } | |
| 106 | - foreach ( $schedule as $v ) { | |
| 107 | - wp_clear_scheduled_hook( $v ); | |
| 108 | - } | |
| 109 | - } | |
| 110 | - /** | |
| 111 | 97 | * Set default options. |
| 112 | 98 | * |
| 113 | 99 | * @return void |
| 114 | 100 | */ |
| @@ -114,14 +100,15 @@ | ||
| 114 | 100 | */ |
| 115 | 101 | public static function set_default_options() { |
| 116 | 102 | $sections = Settings::instance()->get_sections(); |
| 117 | 103 | foreach ( $sections as $sections_id => $section ) { |
| 104 | + $rawOptions = []; | |
| 118 | 105 | if ( ! empty( $section['list'] ) ) { |
| 119 | 106 | foreach ( $section['list'] as $blocks_id => $blocks ) { |
| 120 | - $rawOptions = []; | |
| 121 | 107 | if ( ! rtsb()->has_pro() && 'free' !== ( $blocks['package'] ?? '' ) ) { |
| 122 | 108 | continue; |
| 123 | 109 | } |
| 110 | + | |
| 124 | 111 | $rawOptions['active'] = $blocks['active'] ?? null; |
| 125 | 112 | |
| 126 | 113 | if ( ! empty( $blocks['fields'] ) ) { |
| 127 | 114 | foreach ( $blocks['fields'] as $field_id => $field ) { |
| @@ -128,8 +115,9 @@ | ||
| 128 | 115 | $type = 'array' === gettype( $field['value'] ) ? [] : ''; |
| 129 | 116 | $rawOptions[ $field_id ] = ! empty( $field['value'] ) ? $field['value'] : $type; |
| 130 | 117 | } |
| 131 | 118 | } |
| 119 | + | |
| 132 | 120 | Fns::set_options( $sections_id, $blocks_id, $rawOptions ); |
| 133 | 121 | } |
| 134 | 122 | } |
| 135 | 123 | } |
| @@ -140,8 +128,9 @@ | ||
| 140 | 128 | * |
| 141 | 129 | * @return int |
| 142 | 130 | */ |
| 143 | 131 | public static function create_wc_product() { |
| 132 | + | |
| 144 | 133 | $product = new WC_Product_Simple(); |
| 145 | 134 | $product->set_name( 'Confirm at least one product is created before deleting' ); |
| 146 | 135 | $product->set_description( 'This is a ShopBuilder demo preview product' ); |
| 147 | 136 | $product->set_short_description( 'This is a ShopBuilder product' ); |
| @@ -150,8 +139,12 @@ | ||
| 150 | 139 | $product->set_regular_price( 50 ); |
| 151 | 140 | $product->set_sale_price( 49 ); |
| 152 | 141 | $product->set_price( 49 ); |
| 153 | 142 | |
| 154 | - $product->set_sku( '' ); | |
| 143 | + $product->set_sku( 'SAMPLE-001' ); | |
| 144 | + | |
| 145 | + $product->set_manage_stock( false ); | |
| 146 | + $product->set_stock_status( 'instock' ); | |
| 147 | + | |
| 155 | 148 | return $product->save(); |
| 156 | 149 | } |
| 157 | 150 | } |