Changeset 2094423
- Timestamp:
- 05/24/2019 09:43:31 AM (7 years ago)
- Location:
- dropshipping-woocommerce/trunk
- Files:
-
- 4 added
- 5 edited
-
README.md (added)
-
README.txt (modified) (2 diffs)
-
docs (added)
-
docs/multi-drop-shipper-digram.png (added)
-
docs/multi-drop-shipper-digram.xml (added)
-
dropshipping-woocommerce.php (modified) (1 diff)
-
includes/api/class-dropshipping-woocommerce-handshake.php (modified) (1 diff)
-
includes/class-dropshipping-woocommerce-admin.php (modified) (1 diff)
-
includes/class-dropshipping-woocommerce-common.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dropshipping-woocommerce/trunk/README.txt
r1991490 r2094423 1 1 === Knawat WooCommerce DropShipping === 2 Contributors: dharm1025,knawat 2 Contributors: dharm1025,knawat,esl4m 3 3 Tags: dropshipping, woocommerce, woocommerce dropshipping, dropship, woo dropshipping, knawat, knawat dropshiping 4 4 Requires PHP: 5.3 … … 63 63 * IMPROVEMENT: Some Improvements 64 64 * FIXED: some bug fixes. 65 * ADDED: Knawat handshake. 66 * UPDATED: "start import" button to get all products 65 67 66 68 = 2.0.0 = -
dropshipping-woocommerce/trunk/dropshipping-woocommerce.php
r1991490 r2094423 180 180 if( $this->is_woocommerce_activated() ){ 181 181 // API 182 require_once KNAWAT_DROPWC_PLUGIN_DIR . 'includes/api/class-dropshipping-woocommerce-handshake.php'; 182 add_action("init", function () { 183 require_once( KNAWAT_DROPWC_PLUGIN_DIR . 'includes/api/class-dropshipping-woocommerce-handshake.php'); 184 }); 183 185 require_once KNAWAT_DROPWC_PLUGIN_DIR . 'includes/class-dropshipping-woocommerce-importer.php'; 184 186 require_once KNAWAT_DROPWC_PLUGIN_DIR . 'includes/class-dropshipping-wc-async-request.php'; -
dropshipping-woocommerce/trunk/includes/api/class-dropshipping-woocommerce-handshake.php
r1823194 r2094423 16 16 17 17 if( class_exists( 'WC_REST_System_Status_Controller' ) ): 18 /**19 * @package Knawat_Dropshipping_Woocommerce/API20 * @extends WC_REST_System_Status_Controller21 */22 class Knawat_Dropshipping_Woocommerce_Handshake extends WC_REST_System_Status_Controller {23 24 18 /** 25 * Endpoint namespace. 26 * 27 * @var string 19 * @package Knawat_Dropshipping_Woocommerce/API 20 * @extends WC_REST_System_Status_Controller 28 21 */ 29 protected $namespace = KNAWAT_DROPWC_API_NAMESPACE; 30 31 /** 32 * Route base. 33 * 34 * @var string 35 */ 36 protected $rest_base = 'handshake'; 37 38 39 /** 40 * Register the route for /system_status 41 */ 42 public function register_routes() { 43 register_rest_route( $this->namespace, '/' . $this->rest_base, array( 44 array( 45 'methods' => WP_REST_Server::READABLE, 46 'callback' => array( $this, 'get_site_info' ), 47 'permission_callback' => array( $this, 'get_items_permissions_check' ), 48 'args' => $this->get_collection_params(), 49 ), 50 'schema' => array( $this, 'get_public_item_schema' ), 51 ) ); 22 class Knawat_Dropshipping_Woocommerce_Handshake extends WC_REST_System_Status_Controller { 23 24 /** 25 * Endpoint namespace. 26 * 27 * @var string 28 */ 29 protected $namespace = KNAWAT_DROPWC_API_NAMESPACE; 30 31 /** 32 * Route base. 33 * 34 * @var string 35 */ 36 protected $rest_base = 'handshake'; 37 38 39 /** 40 * Register the route for /system_status 41 */ 42 public function register_routes() { 43 register_rest_route( $this->namespace, '/' . $this->rest_base, array( 44 array( 45 'methods' => WP_REST_Server::READABLE, 46 'callback' => array( $this, 'get_site_info' ), 47 'permission_callback' => array( $this, 'get_items_permissions_check' ), 48 'args' => $this->get_collection_params(), 49 ), 50 'schema' => array( $this, 'get_public_item_schema' ), 51 ) ); 52 } 53 54 /** 55 * Get a system status info, by section. 56 * 57 * @param WP_REST_Request $request Full details about the request. 58 * @return WP_Error|WP_REST_Response 59 */ 60 public function get_site_info( $request ) { 61 $schema = $this->get_item_schema(); 62 // Get default Woo Currency. remove all filters who change front-end currency. 63 remove_all_filters( 'woocommerce_currency' ); 64 remove_all_filters( 'woocommerce_currency_symbol' ); 65 66 $mappings = $this->get_item_mappings(); 67 $response = array(); 68 $skip_sections = array( 'pages', 'database' ); 69 foreach ( $mappings as $section => $values ) { 70 if( in_array( $section, $skip_sections ) ){ 71 continue; 72 } 73 foreach ( $values as $key => $value ) { 74 if ( isset( $schema['properties'][ $section ]['properties'][ $key ]['type'] ) ) { 75 settype( $values[ $key ], $schema['properties'][ $section ]['properties'][ $key ]['type'] ); 76 } 77 } 78 settype( $values, $schema['properties'][ $section ]['type'] ); 79 $response[ $section ] = $values; 80 } 81 82 $response = $this->prepare_item_for_response( $response, $request ); 83 84 return rest_ensure_response( $response ); 85 } 86 87 /** 88 * Get site info like site_name, wp_version, plugins & theme 89 * 90 * @return array 91 */ 92 function knawat_dropshipwc_get_siteinfo(){ 93 $site = array(); 94 $site['name'] = get_bloginfo('name'); 95 $site['url'] = get_site_url(); 96 $site['wp_version'] = get_bloginfo('version'); 97 if( is_multisite() ){ 98 $site['is_multisite'] = 1; 99 }else{ 100 $site['is_multisite'] = 0; 101 } 102 $site['knawat_plugin_version'] = KNAWAT_DROPWC_VERSION; 103 104 $site['plugins'] = $this->knawat_dropshipwc_get_active_plugins(); 105 $site['theme'] = $this->knawat_dropshipwc_get_active_theme(); 106 107 return $site; 108 } 109 110 /** 111 * Get Active theme name & version. 112 * 113 * @return array 114 */ 115 116 public function knawat_dropshipwc_get_active_theme(){ 117 $active_theme = wp_get_theme(); 118 $theme = array(); 119 if( !empty( $active_theme ) ){ 120 $theme['name'] = $active_theme->get('Name'); 121 $theme['theme_uri'] = $active_theme->get('ThemeURI'); 122 $theme['version'] = $active_theme->get('Version'); 123 $theme['stylesheet'] = $active_theme->get_stylesheet(); 124 $theme['template'] = $active_theme->get_template(); 125 } 126 return $theme; 127 } 128 129 /** 130 * Get Active Plugin names & versions. 131 * 132 * @return array 133 */ 134 135 public function knawat_dropshipwc_get_active_plugins(){ 136 137 if ( ! function_exists( 'get_plugins' ) ) { 138 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 139 } 140 $active_plugins = get_option('active_plugins'); 141 $plugins = get_plugins(); 142 $activated_plugins = array(); 143 foreach ($active_plugins as $active_plugin ){ 144 if( isset ( $plugins[$active_plugin] ) ) { 145 $plugin = array(); 146 $plugin['Name'] = $plugins[$active_plugin]['Name']; 147 $plugin['PluginURI'] = $plugins[$active_plugin]['PluginURI']; 148 $plugin['Version'] = $plugins[$active_plugin]['Version']; 149 $activated_plugins[$active_plugin] = $plugin; 150 } 151 } 152 153 return $activated_plugins; 154 } 155 156 /** 157 * Check if Knawat WooCommerce is connected or not. 158 * 159 * @return array 160 */ 161 public function knawat_is_connected(){ 162 $response = array(); 163 $knawat_options = knawat_dropshipwc_get_options(); 164 $token_status = isset( $knawat_options['token_status'] ) ? esc_attr( $knawat_options['token_status'] ) : 'invalid'; 165 if( 'valid' === $token_status ){ 166 $response['message'] = ["Connected"]; 167 }else{ 168 $response['message'] = ["Not connected"]; 169 } 170 return $response; 171 } 172 173 /** 174 * Knawat Return Last sync date. 175 * 176 * @return array 177 */ 178 public function knawat_last_sync_date(){ 179 $response = array(); 180 $token = $this->knawat_is_connected(); 181 if ($token['message'] == 'Connected'){ 182 // Knawat is connected ... and let's get last sync date. 183 $latest = new WP_Query( 184 array( 185 'post_type' => 'product', 186 'post_status' => 'publish', 187 'posts_per_page' => 1, 188 'order' => 'DESC' 189 ) 190 ); 191 if($latest->have_posts()){ 192 $modified_date = $latest->posts[0]->post_modified; 193 $response['message'] = $modified_date; 194 } 195 } 196 return $response; 197 } 52 198 } 53 199 54 /** 55 * Get a system status info, by section. 56 * 57 * @param WP_REST_Request $request Full details about the request. 58 * @return WP_Error|WP_REST_Response 59 */ 60 public function get_site_info( $request ) { 61 $schema = $this->get_item_schema(); 62 // Get default Woo Currency. remove all filters who change front-end currency. 63 remove_all_filters( 'woocommerce_currency' ); 64 remove_all_filters( 'woocommerce_currency_symbol' ); 65 66 $mappings = $this->get_item_mappings(); 67 $response = array(); 68 $skip_sections = array( 'pages', 'database' ); 69 foreach ( $mappings as $section => $values ) { 70 if( in_array( $section, $skip_sections ) ){ 71 continue; 72 } 73 foreach ( $values as $key => $value ) { 74 if ( isset( $schema['properties'][ $section ]['properties'][ $key ]['type'] ) ) { 75 settype( $values[ $key ], $schema['properties'][ $section ]['properties'][ $key ]['type'] ); 76 } 77 } 78 settype( $values, $schema['properties'][ $section ]['type'] ); 79 $response[ $section ] = $values; 80 } 81 82 $response = $this->prepare_item_for_response( $response, $request ); 83 84 return rest_ensure_response( $response ); 85 } 86 87 /** 88 * Get site info like site_name, wp_version, plugins & theme 89 * 90 * @return array 91 */ 92 function knawat_dropshipwc_get_siteinfo(){ 93 $site = array(); 94 $site['name'] = get_bloginfo('name'); 95 $site['url'] = get_site_url(); 96 $site['wp_version'] = get_bloginfo('version'); 97 if( is_multisite() ){ 98 $site['is_multisite'] = 1; 99 }else{ 100 $site['is_multisite'] = 0; 101 } 102 $site['knawat_plugin_version'] = KNAWAT_DROPWC_VERSION; 103 104 $site['plugins'] = $this->knawat_dropshipwc_get_active_plugins(); 105 $site['theme'] = $this->knawat_dropshipwc_get_active_theme(); 106 107 return $site; 108 } 109 110 /** 111 * Get Active theme name & version. 112 * 113 * @return array 114 */ 115 116 public function knawat_dropshipwc_get_active_theme(){ 117 $active_theme = wp_get_theme(); 118 $theme = array(); 119 if( !empty( $active_theme ) ){ 120 $theme['name'] = $active_theme->get('Name'); 121 $theme['theme_uri'] = $active_theme->get('ThemeURI'); 122 $theme['version'] = $active_theme->get('Version'); 123 $theme['stylesheet'] = $active_theme->get_stylesheet(); 124 $theme['template'] = $active_theme->get_template(); 125 } 126 return $theme; 127 } 128 129 /** 130 * Get Active Plugin names & versions. 131 * 132 * @return array 133 */ 134 135 public function knawat_dropshipwc_get_active_plugins(){ 136 137 if ( ! function_exists( 'get_plugins' ) ) { 138 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 139 } 140 $active_plugins = get_option('active_plugins'); 141 $plugins = get_plugins(); 142 $activated_plugins = array(); 143 foreach ($active_plugins as $active_plugin ){ 144 if( isset ( $plugins[$active_plugin] ) ) { 145 $plugin = array(); 146 $plugin['Name'] = $plugins[$active_plugin]['Name']; 147 $plugin['PluginURI'] = $plugins[$active_plugin]['PluginURI']; 148 $plugin['Version'] = $plugins[$active_plugin]['Version']; 149 $activated_plugins[$active_plugin] = $plugin; 150 } 151 } 152 153 return $activated_plugins; 154 } 155 } 156 157 add_action( 'rest_api_init', function () { 158 $knawat_handshake = new Knawat_Dropshipping_Woocommerce_Handshake(); 159 $knawat_handshake->register_routes(); 160 } ); 200 add_action( 'rest_api_init', function () { 201 $knawat_handshake = new Knawat_Dropshipping_Woocommerce_Handshake(); 202 $knawat_handshake->register_routes(); 203 } ); 161 204 162 205 endif; -
dropshipping-woocommerce/trunk/includes/class-dropshipping-woocommerce-admin.php
r1948032 r2094423 427 427 if( wp_verify_nonce( $_GET['manual_nonce'], 'knawatds_manual_import_action') ){ 428 428 global $knawatdswc_errors; 429 do_action( 'knawat_dropshipwc_run_product_import' );429 do_action( 'knawat_dropshipwc_run_product_import', array('force_full_import' => 1) ); 430 430 431 431 if( empty( $knawatdswc_errors ) ){ -
dropshipping-woocommerce/trunk/includes/class-dropshipping-woocommerce-common.php
r1948032 r2094423 96 96 * @return boolean 97 97 */ 98 public function knawat_dropshipwc_backgorund_product_importer( ){98 public function knawat_dropshipwc_backgorund_product_importer($args){ 99 99 $consumer_keys = knawat_dropshipwc_get_consumerkeys(); 100 100 if( empty( $consumer_keys ) ){ … … 128 128 $data = array(); 129 129 $data['limit'] = $product_batch_size; 130 $data = wp_parse_args( $data, $args ); 130 131 $import_process = new Knawat_Dropshipping_WC_Background(); 131 132 $import_process->push_to_queue( $data );
Note: See TracChangeset
for help on using the changeset viewer.