init(); } private function init() { $this->affilio_options = get_option('affilio_option_name'); $aff = $this->affilio_options; } // $type: product | category public function syncMethod($type = null, $quick = false) { $main = new Affilio_Main(); $affilio_options = get_option('affilio_option_name'); $username = $affilio_options['username']; // username $password = affilio_wp_encrypt($affilio_options['password'], 'd'); // password $result = $main->auth_login($username, $password); if ($result) { // var_dump($GLOBALS['bearer']); // echo "Sync_Loading"; if ($type === "category") { $result = $main->init_categories($quick); return; } if ($type === "products") { $resultP = $main->init_products($quick); return; } $result = $main->init_categories($quick); if ($result === true) { $resultP = $main->init_products($quick); if ($resultP === true) { // $msg = '
همگام سازی با موفقیت انجام شد
اتصال به پنل افیلو با موفقیت انجام شد
این افزونه تمامی فرایندهای لازم جهت همگام سازی با پلت فرم افیلیو را به صورت خودکار پیاده سازی میکند.
همگام سازی داده ها |
لطفا اطلاعات زیر را تکمیل نمایید
', isset($this->affilio_options['username']) ? esc_attr($this->affilio_options['username']) : '' ); } public function password_callback() { printf( '', isset($this->affilio_options['password']) ? '***' : '***' ); // printf( // '' // ); } public function webstore_callback() { printf( '', isset($this->affilio_options['webstore']) ? esc_attr($this->affilio_options['webstore']) : '' ); } public function stage_test_callback() { printf('در صورت فعال سازی به محیط آزمایشی افیلیو متصل خواهید شد.
'); printf( ' ', ( isset( $this->affilio_options['is_stage'] ) && $this->affilio_options['is_stage'] === 'is_stage' ) ? 'checked' : '' ); } public function debug_mode_callback() { printf( ' ', ( isset( $this->affilio_options['is_debug'] ) && $this->affilio_options['is_debug'] === 'is_debug' ) ? 'checked' : '' ); } public function status_finalize_callback() { printf( '', isset($this->affilio_options['status_finalize']) ? esc_attr($this->affilio_options['status_finalize']) : 'completed' ); } /* These need to go in your custom plugin (or existing plugin) */ } function affilio_sync_on_product_save($meta_id, $post_id, $meta_key, $meta_value) { if ($meta_key == '_edit_lock') { // we've been editing the post if (get_post_type($post_id) == 'product') { // we've been editing a product $affilio = new Affilio_Main(); $affilio->sync_new_product($post_id); // $product = wc_get_product( $post_id ); // affilio_log_me($post_id); } } } function affilio_update_category_function($category_id) { if (get_term($category_id)->taxonomy == 'product_cat') { // we've been editing a product // affilio_log_me($category_id); // affilio_log_me(get_term($category_id)); $affilio = new Affilio_Main(); $affilio->sync_new_category($category_id); // $product = wc_get_product( $post_id ); // affilio_log_me($post_id); } } if (is_admin()) { $affilio = new AFFILIO(); // do_action('admin_notices', 'success'); add_action('added_post_meta', 'affilio_sync_on_product_save', 10, 4); add_action('updated_post_meta', 'affilio_sync_on_product_save', 10, 4); add_action('created_term', 'affilio_update_category_function', 10, 4); add_action('edited_terms', 'affilio_update_category_function', 10, 4); }