Plugin Directory

Changeset 2741087


Ignore:
Timestamp:
06/12/2022 08:40:28 AM (4 years ago)
Author:
avitrop
Message:

Update to version 2.2.3 from GitHub

Location:
storeman
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • storeman/tags/2.2.3/.vscode/launch.json

    r2656190 r2741087  
    66    "configurations": [
    77        {
    8             "name": "Listen for XDebug",
     8            "name": "Listen for Xdebug",
    99            "type": "php",
    1010            "request": "launch",
    11             "port": 9000
     11            "port": 9003
    1212        },
    1313        {
     
    1717            "program": "${file}",
    1818            "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            }
    2046        }
    2147    ]
  • storeman/tags/2.2.3/README.txt

    r2721958 r2741087  
    44Requires at lest: 3.0.1
    55Tested up to: 6.0
    6 Stable tag: 2.2.2
     6Stable tag: 2.2.3
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3333
    3434== Changelog ==
     35= 2.2.3 =
     36add order item float support
    3537= 2.2.2 =
    3638prevent shut down hooks
  • storeman/tags/2.2.3/admin/class-storeman-admin.php

    r2721958 r2741087  
    130130                // strpos($webhook->get_delivery_url(), 'crm.sharpen') !== false
    131131                // )
    132                 && 
     132                &&
    133133                $this->removeElementId === $id
    134134        ) {
     
    158158        return $object;
    159159    }
    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'])) {
    163171            $c['stock_quantity']['type'] = 'float';
    164172        }
     
    182190        return $object;
    183191    }
    184     public function overrule_webhook_disable_limit( $number ) {
     192    public function overrule_webhook_disable_limit($number)
     193    {
    185194        return 99;
    186195    }
     
    190199        return $object;
    191200    }
    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            }
    230239        }
    231240        $data = $response->get_data();
    232241        $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    }
    277287    public function fix_hebrew_taxonomy_bug($variation, $request)
    278288    {
     
    324334                    if ($term && ! is_wp_error($term)) {
    325335                        $attribute_value = $term->slug;
    326                         // $attribute_value = sanitize_title($attribute_value);
     336                    // $attribute_value = sanitize_title($attribute_value);
    327337                    } else {
    328338                        $attribute_value = sanitize_title($attribute_value);
     
    415425//     return true;
    416426//         });
    417 
  • storeman/tags/2.2.3/includes/class-storeman.php

    r2721958 r2741087  
    194194            $this->loader->add_filter( 'woocommerce_rest_' . $post_type . '_schema', $plugin_admin,'set_get_item_schema');
    195195        }
     196        $this->loader->add_filter( 'woocommerce_rest_shop_order_schema', $plugin_admin,'set_get_order_schema');
     197
    196198        $this->loader->add_action("woocommerce_rest_pre_insert_product_variation_object", $plugin_admin, 'remove_product_variation_webhook_action',1,3);
    197199        $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  
    1717 * Plugin URI:        https://storeman.co.il
    1818 * Description:       add storeman to your WordPress site.
    19  * Version:           2.2.2
     19 * Version:           2.2.3
    2020 * Author:            avitrop
    2121 * Author URI:        https://profiles.wordpress.org/avitrop/
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'STOREMAN_VERSION', '2.2.2' );
     38define( 'STOREMAN_VERSION', '2.2.3' );
    3939
    4040/**
  • storeman/trunk/.vscode/launch.json

    r2656190 r2741087  
    66    "configurations": [
    77        {
    8             "name": "Listen for XDebug",
     8            "name": "Listen for Xdebug",
    99            "type": "php",
    1010            "request": "launch",
    11             "port": 9000
     11            "port": 9003
    1212        },
    1313        {
     
    1717            "program": "${file}",
    1818            "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            }
    2046        }
    2147    ]
  • storeman/trunk/README.txt

    r2721958 r2741087  
    44Requires at lest: 3.0.1
    55Tested up to: 6.0
    6 Stable tag: 2.2.2
     6Stable tag: 2.2.3
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3333
    3434== Changelog ==
     35= 2.2.3 =
     36add order item float support
    3537= 2.2.2 =
    3638prevent shut down hooks
  • storeman/trunk/admin/class-storeman-admin.php

    r2721958 r2741087  
    130130                // strpos($webhook->get_delivery_url(), 'crm.sharpen') !== false
    131131                // )
    132                 && 
     132                &&
    133133                $this->removeElementId === $id
    134134        ) {
     
    158158        return $object;
    159159    }
    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'])) {
    163171            $c['stock_quantity']['type'] = 'float';
    164172        }
     
    182190        return $object;
    183191    }
    184     public function overrule_webhook_disable_limit( $number ) {
     192    public function overrule_webhook_disable_limit($number)
     193    {
    185194        return 99;
    186195    }
     
    190199        return $object;
    191200    }
    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            }
    230239        }
    231240        $data = $response->get_data();
    232241        $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    }
    277287    public function fix_hebrew_taxonomy_bug($variation, $request)
    278288    {
     
    324334                    if ($term && ! is_wp_error($term)) {
    325335                        $attribute_value = $term->slug;
    326                         // $attribute_value = sanitize_title($attribute_value);
     336                    // $attribute_value = sanitize_title($attribute_value);
    327337                    } else {
    328338                        $attribute_value = sanitize_title($attribute_value);
     
    415425//     return true;
    416426//         });
    417 
  • storeman/trunk/includes/class-storeman.php

    r2721958 r2741087  
    194194            $this->loader->add_filter( 'woocommerce_rest_' . $post_type . '_schema', $plugin_admin,'set_get_item_schema');
    195195        }
     196        $this->loader->add_filter( 'woocommerce_rest_shop_order_schema', $plugin_admin,'set_get_order_schema');
     197
    196198        $this->loader->add_action("woocommerce_rest_pre_insert_product_variation_object", $plugin_admin, 'remove_product_variation_webhook_action',1,3);
    197199        $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  
    1717 * Plugin URI:        https://storeman.co.il
    1818 * Description:       add storeman to your WordPress site.
    19  * Version:           2.2.2
     19 * Version:           2.2.3
    2020 * Author:            avitrop
    2121 * Author URI:        https://profiles.wordpress.org/avitrop/
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'STOREMAN_VERSION', '2.2.2' );
     38define( 'STOREMAN_VERSION', '2.2.3' );
    3939
    4040/**
Note: See TracChangeset for help on using the changeset viewer.