Changeset 2741087
- Timestamp:
- 06/12/2022 08:40:28 AM (4 years ago)
- Location:
- storeman
- Files:
-
- 10 edited
- 1 copied
-
tags/2.2.3 (copied) (copied from storeman/trunk)
-
tags/2.2.3/.vscode/launch.json (modified) (2 diffs)
-
tags/2.2.3/README.txt (modified) (2 diffs)
-
tags/2.2.3/admin/class-storeman-admin.php (modified) (6 diffs)
-
tags/2.2.3/includes/class-storeman.php (modified) (1 diff)
-
tags/2.2.3/storeman.php (modified) (2 diffs)
-
trunk/.vscode/launch.json (modified) (2 diffs)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/admin/class-storeman-admin.php (modified) (6 diffs)
-
trunk/includes/class-storeman.php (modified) (1 diff)
-
trunk/storeman.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
storeman/tags/2.2.3/.vscode/launch.json
r2656190 r2741087 6 6 "configurations": [ 7 7 { 8 "name": "Listen for X Debug",8 "name": "Listen for Xdebug", 9 9 "type": "php", 10 10 "request": "launch", 11 "port": 900 011 "port": 9003 12 12 }, 13 13 { … … 17 17 "program": "${file}", 18 18 "cwd": "${fileDirname}", 19 "port": 9000 19 "port": 0, 20 "runtimeArgs": [ 21 "-dxdebug.start_with_request=yes" 22 ], 23 "env": { 24 "XDEBUG_MODE": "debug,develop", 25 "XDEBUG_CONFIG": "client_port=${port}" 26 } 27 }, 28 { 29 "name": "Launch Built-in web server", 30 "type": "php", 31 "request": "launch", 32 "runtimeArgs": [ 33 "-dxdebug.mode=debug", 34 "-dxdebug.start_with_request=yes", 35 "-S", 36 "localhost:0" 37 ], 38 "program": "", 39 "cwd": "${workspaceRoot}", 40 "port": 9003, 41 "serverReadyAction": { 42 "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started", 43 "uriFormat": "http://localhost:%s", 44 "action": "openExternally" 45 } 20 46 } 21 47 ] -
storeman/tags/2.2.3/README.txt
r2721958 r2741087 4 4 Requires at lest: 3.0.1 5 5 Tested up to: 6.0 6 Stable tag: 2.2. 26 Stable tag: 2.2.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 33 33 34 34 == Changelog == 35 = 2.2.3 = 36 add order item float support 35 37 = 2.2.2 = 36 38 prevent shut down hooks -
storeman/tags/2.2.3/admin/class-storeman-admin.php
r2721958 r2741087 130 130 // strpos($webhook->get_delivery_url(), 'crm.sharpen') !== false 131 131 // ) 132 && 132 && 133 133 $this->removeElementId === $id 134 134 ) { … … 158 158 return $object; 159 159 } 160 161 public function set_get_item_schema($c){ 162 if(apply_filters('storeman_stock_quantity_doubleval',false) && isset($c['stock_quantity'])){ 160 public function set_get_order_schema($c) 161 { 162 if (apply_filters('storeman_stock_quantity_doubleval', false)) { 163 $c['line_items']['items']['properties']['quantity']['type'] = 'float'; 164 } 165 166 return $c; 167 } 168 public function set_get_item_schema($c) 169 { 170 if (apply_filters('storeman_stock_quantity_doubleval', false) && isset($c['stock_quantity'])) { 163 171 $c['stock_quantity']['type'] = 'float'; 164 172 } … … 182 190 return $object; 183 191 } 184 public function overrule_webhook_disable_limit( $number ) { 192 public function overrule_webhook_disable_limit($number) 193 { 185 194 return 99; 186 195 } … … 190 199 return $object; 191 200 } 192 public function add_attribute_options_slugs($response, $product, $request ){193 if ( $product->is_type( 'variation' ) ){194 $_product = wc_get_product( $product->get_parent_id() ); 195 foreach ( $product->get_variation_attributes() as $attribute_name => $attribute ) { 196 $name = str_replace( 'attribute_', '', $attribute_name ); 197 198 if ( empty( $attribute ) && '0' !== $attribute ) { 199 continue; 200 } 201 202 // Taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_`. 203 if ( 0 === strpos( $attribute_name, 'attribute_pa_' ) ) { 204 $option_term = get_term_by( 'slug', $attribute, $name ); 205 $attributes[] = array( 206 'id' => wc_attribute_taxonomy_id_by_name( $name ), 207 'name' => $this->get_attribute_taxonomy_name( $name, $_product),208 'option' => $option_term && ! is_wp_error( $option_term ) ? $option_term->slug : $attribute,209 ); 210 } else { 211 $attributes[] = array( 212 'id' => 0, 213 'name' => $this->get_attribute_taxonomy_name( $name, $_product ),214 'option' => $attribute,215 ); 216 } 217 }218 }219 else{220 foreach ( $product->get_attributes() as $attribute) {221 $attributes[] = array(222 'id' => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name( $attribute['name']) : 0,223 'name' => $this->get_attribute_taxonomy_name( $attribute['name'], $product),224 'position' => (int) $attribute['position'],225 'visible' => (bool) $attribute['is_visible'],226 'variation' => (bool) $attribute['is_variation'],227 'options' => $this->get_attribute_options( $product->get_id(), $attribute),228 );229 } 201 public function add_attribute_options_slugs($response, $product, $request) 202 { 203 if ($product->is_type('variation')) { 204 $_product = wc_get_product($product->get_parent_id()); 205 foreach ($product->get_variation_attributes() as $attribute_name => $attribute) { 206 $name = str_replace('attribute_', '', $attribute_name); 207 208 if (empty($attribute) && '0' !== $attribute) { 209 continue; 210 } 211 212 // Taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_`. 213 if (0 === strpos($attribute_name, 'attribute_pa_')) { 214 $option_term = get_term_by('slug', $attribute, $name); 215 $attributes[] = array( 216 'id' => wc_attribute_taxonomy_id_by_name($name), 217 'name' => $this->get_attribute_taxonomy_name($name, $_product), 218 'option' => $option_term && ! is_wp_error($option_term) ? $option_term->slug : $attribute, 219 ); 220 } else { 221 $attributes[] = array( 222 'id' => 0, 223 'name' => $this->get_attribute_taxonomy_name($name, $_product), 224 'option' => $attribute, 225 ); 226 } 227 } 228 } else { 229 foreach ($product->get_attributes() as $attribute) { 230 $attributes[] = array( 231 'id' => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name($attribute['name']) : 0, 232 'name' => $this->get_attribute_taxonomy_name($attribute['name'], $product), 233 'position' => (int) $attribute['position'], 234 'visible' => (bool) $attribute['is_visible'], 235 'variation' => (bool) $attribute['is_variation'], 236 'options' => $this->get_attribute_options($product->get_id(), $attribute), 237 ); 238 } 230 239 } 231 240 $data = $response->get_data(); 232 241 $data['attributes'] = $attributes; 233 return rest_ensure_response( $data ); 234 235 } 236 protected function get_attribute_taxonomy_name( $slug, $product ) { 237 // Format slug so it matches attributes of the product. 238 $slug = wc_attribute_taxonomy_slug( $slug ); 239 $attributes = $product->get_attributes(); 240 $attribute = false; 241 242 // pa_ attributes. 243 if ( isset( $attributes[ wc_attribute_taxonomy_name( $slug ) ] ) ) { 244 $attribute = $attributes[ wc_attribute_taxonomy_name( $slug ) ]; 245 } elseif ( isset( $attributes[ $slug ] ) ) { 246 $attribute = $attributes[ $slug ]; 247 } 248 249 if ( ! $attribute ) { 250 return $slug; 251 } 252 253 // Taxonomy attribute name. 254 if ( $attribute->is_taxonomy() ) { 255 $taxonomy = $attribute->get_taxonomy_object(); 256 return $taxonomy->attribute_label; 257 } 258 259 // Custom product attribute name. 260 return $attribute->get_name(); 261 } 262 protected function get_attribute_options( $product_id, $attribute ) { 263 if ( isset( $attribute['is_taxonomy'] ) && $attribute['is_taxonomy'] ) { 264 return wc_get_product_terms( 265 $product_id, 266 $attribute['name'], 267 array( 268 'fields' => 'slugs', 269 ) 270 ); 271 } elseif ( isset( $attribute['value'] ) ) { 272 return array_map( 'trim', explode( '|', $attribute['value'] ) ); 273 } 274 275 return array(); 276 } 242 return rest_ensure_response($data); 243 } 244 protected function get_attribute_taxonomy_name($slug, $product) 245 { 246 // Format slug so it matches attributes of the product. 247 $slug = wc_attribute_taxonomy_slug($slug); 248 $attributes = $product->get_attributes(); 249 $attribute = false; 250 251 // pa_ attributes. 252 if (isset($attributes[ wc_attribute_taxonomy_name($slug) ])) { 253 $attribute = $attributes[ wc_attribute_taxonomy_name($slug) ]; 254 } elseif (isset($attributes[ $slug ])) { 255 $attribute = $attributes[ $slug ]; 256 } 257 258 if (! $attribute) { 259 return $slug; 260 } 261 262 // Taxonomy attribute name. 263 if ($attribute->is_taxonomy()) { 264 $taxonomy = $attribute->get_taxonomy_object(); 265 return $taxonomy->attribute_label; 266 } 267 268 // Custom product attribute name. 269 return $attribute->get_name(); 270 } 271 protected function get_attribute_options($product_id, $attribute) 272 { 273 if (isset($attribute['is_taxonomy']) && $attribute['is_taxonomy']) { 274 return wc_get_product_terms( 275 $product_id, 276 $attribute['name'], 277 array( 278 'fields' => 'slugs', 279 ) 280 ); 281 } elseif (isset($attribute['value'])) { 282 return array_map('trim', explode('|', $attribute['value'])); 283 } 284 285 return array(); 286 } 277 287 public function fix_hebrew_taxonomy_bug($variation, $request) 278 288 { … … 324 334 if ($term && ! is_wp_error($term)) { 325 335 $attribute_value = $term->slug; 326 // $attribute_value = sanitize_title($attribute_value);336 // $attribute_value = sanitize_title($attribute_value); 327 337 } else { 328 338 $attribute_value = sanitize_title($attribute_value); … … 415 425 // return true; 416 426 // }); 417 -
storeman/tags/2.2.3/includes/class-storeman.php
r2721958 r2741087 194 194 $this->loader->add_filter( 'woocommerce_rest_' . $post_type . '_schema', $plugin_admin,'set_get_item_schema'); 195 195 } 196 $this->loader->add_filter( 'woocommerce_rest_shop_order_schema', $plugin_admin,'set_get_order_schema'); 197 196 198 $this->loader->add_action("woocommerce_rest_pre_insert_product_variation_object", $plugin_admin, 'remove_product_variation_webhook_action',1,3); 197 199 $this->loader->add_action("woocommerce_rest_insert_product_variation_object", $plugin_admin, 'remove_product_variation_webhook_action',999,3); -
storeman/tags/2.2.3/storeman.php
r2721958 r2741087 17 17 * Plugin URI: https://storeman.co.il 18 18 * Description: add storeman to your WordPress site. 19 * Version: 2.2. 219 * Version: 2.2.3 20 20 * Author: avitrop 21 21 * Author URI: https://profiles.wordpress.org/avitrop/ … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'STOREMAN_VERSION', '2.2. 2' );38 define( 'STOREMAN_VERSION', '2.2.3' ); 39 39 40 40 /** -
storeman/trunk/.vscode/launch.json
r2656190 r2741087 6 6 "configurations": [ 7 7 { 8 "name": "Listen for X Debug",8 "name": "Listen for Xdebug", 9 9 "type": "php", 10 10 "request": "launch", 11 "port": 900 011 "port": 9003 12 12 }, 13 13 { … … 17 17 "program": "${file}", 18 18 "cwd": "${fileDirname}", 19 "port": 9000 19 "port": 0, 20 "runtimeArgs": [ 21 "-dxdebug.start_with_request=yes" 22 ], 23 "env": { 24 "XDEBUG_MODE": "debug,develop", 25 "XDEBUG_CONFIG": "client_port=${port}" 26 } 27 }, 28 { 29 "name": "Launch Built-in web server", 30 "type": "php", 31 "request": "launch", 32 "runtimeArgs": [ 33 "-dxdebug.mode=debug", 34 "-dxdebug.start_with_request=yes", 35 "-S", 36 "localhost:0" 37 ], 38 "program": "", 39 "cwd": "${workspaceRoot}", 40 "port": 9003, 41 "serverReadyAction": { 42 "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started", 43 "uriFormat": "http://localhost:%s", 44 "action": "openExternally" 45 } 20 46 } 21 47 ] -
storeman/trunk/README.txt
r2721958 r2741087 4 4 Requires at lest: 3.0.1 5 5 Tested up to: 6.0 6 Stable tag: 2.2. 26 Stable tag: 2.2.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 33 33 34 34 == Changelog == 35 = 2.2.3 = 36 add order item float support 35 37 = 2.2.2 = 36 38 prevent shut down hooks -
storeman/trunk/admin/class-storeman-admin.php
r2721958 r2741087 130 130 // strpos($webhook->get_delivery_url(), 'crm.sharpen') !== false 131 131 // ) 132 && 132 && 133 133 $this->removeElementId === $id 134 134 ) { … … 158 158 return $object; 159 159 } 160 161 public function set_get_item_schema($c){ 162 if(apply_filters('storeman_stock_quantity_doubleval',false) && isset($c['stock_quantity'])){ 160 public function set_get_order_schema($c) 161 { 162 if (apply_filters('storeman_stock_quantity_doubleval', false)) { 163 $c['line_items']['items']['properties']['quantity']['type'] = 'float'; 164 } 165 166 return $c; 167 } 168 public function set_get_item_schema($c) 169 { 170 if (apply_filters('storeman_stock_quantity_doubleval', false) && isset($c['stock_quantity'])) { 163 171 $c['stock_quantity']['type'] = 'float'; 164 172 } … … 182 190 return $object; 183 191 } 184 public function overrule_webhook_disable_limit( $number ) { 192 public function overrule_webhook_disable_limit($number) 193 { 185 194 return 99; 186 195 } … … 190 199 return $object; 191 200 } 192 public function add_attribute_options_slugs($response, $product, $request ){193 if ( $product->is_type( 'variation' ) ){194 $_product = wc_get_product( $product->get_parent_id() ); 195 foreach ( $product->get_variation_attributes() as $attribute_name => $attribute ) { 196 $name = str_replace( 'attribute_', '', $attribute_name ); 197 198 if ( empty( $attribute ) && '0' !== $attribute ) { 199 continue; 200 } 201 202 // Taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_`. 203 if ( 0 === strpos( $attribute_name, 'attribute_pa_' ) ) { 204 $option_term = get_term_by( 'slug', $attribute, $name ); 205 $attributes[] = array( 206 'id' => wc_attribute_taxonomy_id_by_name( $name ), 207 'name' => $this->get_attribute_taxonomy_name( $name, $_product),208 'option' => $option_term && ! is_wp_error( $option_term ) ? $option_term->slug : $attribute,209 ); 210 } else { 211 $attributes[] = array( 212 'id' => 0, 213 'name' => $this->get_attribute_taxonomy_name( $name, $_product ),214 'option' => $attribute,215 ); 216 } 217 }218 }219 else{220 foreach ( $product->get_attributes() as $attribute) {221 $attributes[] = array(222 'id' => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name( $attribute['name']) : 0,223 'name' => $this->get_attribute_taxonomy_name( $attribute['name'], $product),224 'position' => (int) $attribute['position'],225 'visible' => (bool) $attribute['is_visible'],226 'variation' => (bool) $attribute['is_variation'],227 'options' => $this->get_attribute_options( $product->get_id(), $attribute),228 );229 } 201 public function add_attribute_options_slugs($response, $product, $request) 202 { 203 if ($product->is_type('variation')) { 204 $_product = wc_get_product($product->get_parent_id()); 205 foreach ($product->get_variation_attributes() as $attribute_name => $attribute) { 206 $name = str_replace('attribute_', '', $attribute_name); 207 208 if (empty($attribute) && '0' !== $attribute) { 209 continue; 210 } 211 212 // Taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_`. 213 if (0 === strpos($attribute_name, 'attribute_pa_')) { 214 $option_term = get_term_by('slug', $attribute, $name); 215 $attributes[] = array( 216 'id' => wc_attribute_taxonomy_id_by_name($name), 217 'name' => $this->get_attribute_taxonomy_name($name, $_product), 218 'option' => $option_term && ! is_wp_error($option_term) ? $option_term->slug : $attribute, 219 ); 220 } else { 221 $attributes[] = array( 222 'id' => 0, 223 'name' => $this->get_attribute_taxonomy_name($name, $_product), 224 'option' => $attribute, 225 ); 226 } 227 } 228 } else { 229 foreach ($product->get_attributes() as $attribute) { 230 $attributes[] = array( 231 'id' => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name($attribute['name']) : 0, 232 'name' => $this->get_attribute_taxonomy_name($attribute['name'], $product), 233 'position' => (int) $attribute['position'], 234 'visible' => (bool) $attribute['is_visible'], 235 'variation' => (bool) $attribute['is_variation'], 236 'options' => $this->get_attribute_options($product->get_id(), $attribute), 237 ); 238 } 230 239 } 231 240 $data = $response->get_data(); 232 241 $data['attributes'] = $attributes; 233 return rest_ensure_response( $data ); 234 235 } 236 protected function get_attribute_taxonomy_name( $slug, $product ) { 237 // Format slug so it matches attributes of the product. 238 $slug = wc_attribute_taxonomy_slug( $slug ); 239 $attributes = $product->get_attributes(); 240 $attribute = false; 241 242 // pa_ attributes. 243 if ( isset( $attributes[ wc_attribute_taxonomy_name( $slug ) ] ) ) { 244 $attribute = $attributes[ wc_attribute_taxonomy_name( $slug ) ]; 245 } elseif ( isset( $attributes[ $slug ] ) ) { 246 $attribute = $attributes[ $slug ]; 247 } 248 249 if ( ! $attribute ) { 250 return $slug; 251 } 252 253 // Taxonomy attribute name. 254 if ( $attribute->is_taxonomy() ) { 255 $taxonomy = $attribute->get_taxonomy_object(); 256 return $taxonomy->attribute_label; 257 } 258 259 // Custom product attribute name. 260 return $attribute->get_name(); 261 } 262 protected function get_attribute_options( $product_id, $attribute ) { 263 if ( isset( $attribute['is_taxonomy'] ) && $attribute['is_taxonomy'] ) { 264 return wc_get_product_terms( 265 $product_id, 266 $attribute['name'], 267 array( 268 'fields' => 'slugs', 269 ) 270 ); 271 } elseif ( isset( $attribute['value'] ) ) { 272 return array_map( 'trim', explode( '|', $attribute['value'] ) ); 273 } 274 275 return array(); 276 } 242 return rest_ensure_response($data); 243 } 244 protected function get_attribute_taxonomy_name($slug, $product) 245 { 246 // Format slug so it matches attributes of the product. 247 $slug = wc_attribute_taxonomy_slug($slug); 248 $attributes = $product->get_attributes(); 249 $attribute = false; 250 251 // pa_ attributes. 252 if (isset($attributes[ wc_attribute_taxonomy_name($slug) ])) { 253 $attribute = $attributes[ wc_attribute_taxonomy_name($slug) ]; 254 } elseif (isset($attributes[ $slug ])) { 255 $attribute = $attributes[ $slug ]; 256 } 257 258 if (! $attribute) { 259 return $slug; 260 } 261 262 // Taxonomy attribute name. 263 if ($attribute->is_taxonomy()) { 264 $taxonomy = $attribute->get_taxonomy_object(); 265 return $taxonomy->attribute_label; 266 } 267 268 // Custom product attribute name. 269 return $attribute->get_name(); 270 } 271 protected function get_attribute_options($product_id, $attribute) 272 { 273 if (isset($attribute['is_taxonomy']) && $attribute['is_taxonomy']) { 274 return wc_get_product_terms( 275 $product_id, 276 $attribute['name'], 277 array( 278 'fields' => 'slugs', 279 ) 280 ); 281 } elseif (isset($attribute['value'])) { 282 return array_map('trim', explode('|', $attribute['value'])); 283 } 284 285 return array(); 286 } 277 287 public function fix_hebrew_taxonomy_bug($variation, $request) 278 288 { … … 324 334 if ($term && ! is_wp_error($term)) { 325 335 $attribute_value = $term->slug; 326 // $attribute_value = sanitize_title($attribute_value);336 // $attribute_value = sanitize_title($attribute_value); 327 337 } else { 328 338 $attribute_value = sanitize_title($attribute_value); … … 415 425 // return true; 416 426 // }); 417 -
storeman/trunk/includes/class-storeman.php
r2721958 r2741087 194 194 $this->loader->add_filter( 'woocommerce_rest_' . $post_type . '_schema', $plugin_admin,'set_get_item_schema'); 195 195 } 196 $this->loader->add_filter( 'woocommerce_rest_shop_order_schema', $plugin_admin,'set_get_order_schema'); 197 196 198 $this->loader->add_action("woocommerce_rest_pre_insert_product_variation_object", $plugin_admin, 'remove_product_variation_webhook_action',1,3); 197 199 $this->loader->add_action("woocommerce_rest_insert_product_variation_object", $plugin_admin, 'remove_product_variation_webhook_action',999,3); -
storeman/trunk/storeman.php
r2721958 r2741087 17 17 * Plugin URI: https://storeman.co.il 18 18 * Description: add storeman to your WordPress site. 19 * Version: 2.2. 219 * Version: 2.2.3 20 20 * Author: avitrop 21 21 * Author URI: https://profiles.wordpress.org/avitrop/ … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'STOREMAN_VERSION', '2.2. 2' );38 define( 'STOREMAN_VERSION', '2.2.3' ); 39 39 40 40 /**
Note: See TracChangeset
for help on using the changeset viewer.