Plugin Directory

Changeset 2176233


Ignore:
Timestamp:
10/19/2019 10:45:42 PM (6 years ago)
Author:
dragosmicu
Message:

Update to version 1.1.2. Fixed bugs.

Location:
wootomation/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wootomation/trunk/includes/class-admin.php

    r2176202 r2176233  
    66 *
    77 * @package Wootomation
    8  * @version 1.1.0
     8 * @version 1.1.2
    99 */
    1010
     
    3131            <form method="post" action="options.php">
    3232                <?php settings_fields( 'wootomation-settings' ); ?>
    33                 <?php settings_fields( 'wootomation-locations' ); ?>
     33                <?php //settings_fields( 'wootomation-locations' ); ?>
    3434                <?php do_settings_sections( 'woocommerce' ); ?>
    3535                <?php submit_button(); ?>
     
    4141        // Register settings
    4242        register_setting( 'wootomation-settings', 'wootomation_suggestions_per_page' );
    43         register_setting( 'wootomation-locations', 'wootomation_after_cart_table' );
    44         register_setting( 'wootomation-locations', 'wootomation_after_cart_table_title' );
     43        register_setting( 'wootomation-settings', 'wootomation_after_cart_table' );
     44        register_setting( 'wootomation-settings', 'wootomation_after_cart_table_title' );
    4545       
    4646        // Register sections
    4747        add_settings_section( 'wootomation-settings', 'General Settings', array($this, 'wootomation_settings'), 'woocommerce' );
    48         add_settings_section( 'wootomation-locations', 'Locations', array($this, 'wootomation_locations'), 'woocommerce' );
     48        // add_settings_section( 'wootomation-location', 'Locations', array($this, 'wootomation_locations'), 'woocommerce' );
    4949       
    5050        // Register fields
    5151        add_settings_field( 'wootomation-suggestions_per_page', 'Suggestions to show' , array($this, 'wootomation_suggestions_per_page'), 'woocommerce', 'wootomation-settings' );
    52         add_settings_field( 'wootomation-after-cart-table', 'Add to cart (after cart table)' , array($this, 'wootomation_after_cart_table'), 'woocommerce', 'wootomation-locations' );
    53         add_settings_field( 'wootomation-after-cart-table-title', 'Title' , array($this, 'wootomation_after_cart_table_title'), 'woocommerce', 'wootomation-locations' );
     52        add_settings_field( 'wootomation-after-cart-table', 'Add to cart (after cart table)' , array($this, 'wootomation_after_cart_table'), 'woocommerce', 'wootomation-settings' );
     53        add_settings_field( 'wootomation-after-cart-table-title', 'Title' , array($this, 'wootomation_after_cart_table_title'), 'woocommerce', 'wootomation-settings' );
    5454    }
    5555
     
    6363
    6464    public function wootomation_suggestions_per_page(){
    65         $option = esc_attr( get_site_option('wootomation_suggestions_per_page') );
     65        $option = esc_attr( get_option('wootomation_suggestions_per_page') );
    6666        echo '<input type="number" name="wootomation_suggestions_per_page" value="'.$option.'" placeholder="3" />';
    6767    }
    6868
    6969    public function wootomation_after_cart_table(){
    70         $option = esc_attr( get_site_option('wootomation_after_cart_table') );
     70        $option = esc_attr( get_option('wootomation_after_cart_table') );
    7171        $html = '<label class="switch">';
    7272            $html .= '<input type="checkbox" name="wootomation_after_cart_table" value="1"' . checked( 1, $option, false ) .  '/>';
     
    7777
    7878    public function wootomation_after_cart_table_title(){
    79         $option = esc_attr( get_site_option('wootomation_after_cart_table_title') );
     79        $option = esc_attr( get_option('wootomation_after_cart_table_title') );
    8080        echo '<input type="text" name="wootomation_after_cart_table_title" value="'.$option.'" placeholder="People who bought this, also bought…" class="regular-text" />';
    8181    }
  • wootomation/trunk/includes/class-ai.php

    r2176195 r2176233  
    66 *
    77 * @package Wootomation
    8  * @version 1.1.0
     8 * @version 1.1.2
    99 */
    1010
  • wootomation/trunk/readme.txt

    r2176202 r2176233  
    3939== Changelog ==
    4040
     41= 1.1.2 =
     42* Fixed admin page bug.
     43
    4144= 1.1.1 =
    42 * Added multisite support.
     45* Improved multisite support.
    4346
    4447= 1.1.0 =
     
    5558== Upgrade Notice ==
    5659
     60= 1.1.2 =
     61* Fixed admin page bug.
     62
    5763= 1.1.1 =
    58 Added multisite support.
     64Improved multisite support.
    5965
    6066= 1.1.0 =
  • wootomation/trunk/wootomation.php

    r2176205 r2176233  
    44 * Plugin URI: https://wordpress.org/support/plugin/wootomation/
    55 * Description: 🤖 Increase the sales of your WooCommerce shop by suggesting the right products to your customers, with the help of Machine Learning Artificial Intelligence. To take advantage of its power, just install and activate, it works out of the box.
    6  * Version: 1.1.1
    7  * Stable tag: 1.1.1
     6 * Version: 1.1.2
     7 * Stable tag: 1.1.2
    88 * Author: Dragos Micu
    99 * Author URI: https://wordpress.org/support/users/dragosmicu/
     
    3232            $this->plugin_name = plugin_basename( __FILE__ );
    3333            $this->ajax_url = admin_url('admin-ajax.php');
    34             $this->suggestions_per_page = get_site_option('wootomation_suggestions_per_page') ? get_site_option('wootomation_suggestions_per_page') : 3;
    35             $this->location = esc_attr( get_site_option('wootomation_after_cart_table') );
     34            $this->suggestions_per_page = get_option('wootomation_suggestions_per_page') ? get_option('wootomation_suggestions_per_page') : 3;
     35            $this->location = esc_attr( get_option('wootomation_after_cart_table') );
    3636            $this->titles = apply_filters( 'wootomation_titles', array(
    37                 'wootomation_after_cart_table_title' => get_site_option('wootomation_after_cart_table_title') ? get_site_option('wootomation_after_cart_table_title') : "People who bought this, also bought&hellip;",
     37                'wootomation_after_cart_table_title' => get_option('wootomation_after_cart_table_title') ? get_option('wootomation_after_cart_table_title') : "People who bought this, also bought&hellip;",
    3838            ));
    3939
     
    8181        public function deactivate() {
    8282            flush_rewrite_rules();
    83             delete_site_option( 'wt-donate' );
    84             delete_site_option( 'wt-hide-review' );
    8583        }
    8684
     
    111109            if( !get_site_transient( 'wt-admin-notices-after-one-month' ) ){
    112110                // check if wt-hide-review option doesn't exist
    113                 if( false === get_site_option('wt-hide-review' ) ) {
     111                if( false === get_option('wt-hide-review' ) ) {
    114112                    // then check for "Dismiss" GET request
    115113                    if( isset( $_GET['wt-hide-review'] ) ):
    116114                        // If GET request to hide notice exists, add option
    117115                        if( $_GET['wt-hide-review'] === 'true' ):
    118                             add_site_option('wt-hide-review', 'true');
     116                            add_option('wt-hide-review', 'true');
    119117                        endif;
    120118                    // If GET request doesn't exist, continue displaying notice
     
    130128            if( !get_site_transient( 'wt-admin-notices-after-two-months' ) ){
    131129                // check if wt-donate option doesn't exist
    132                 if( false === get_site_option( 'wt-donate' ) ) {
     130                if( false === get_option( 'wt-donate' ) ) {
    133131                    // then check for "Dismiss" GET request
    134132                    if( isset( $_GET['wt-donate'] ) ):
    135133                        // If GET request to hide notice exists, add option
    136134                        if( $_GET['wt-donate'] === 'true' ):
    137                             add_site_option('wt-donate', 'true');
     135                            add_option('wt-donate', 'true');
    138136                        endif;
    139137                    // If GET request doesn't exist, continue displaying notice
     
    181179            $associator = Wootomation_AI::train($sales);
    182180
    183             update_option( 'wootomation-associator', $associator );
     181            update_site_option( 'wootomation-associator', $associator );
    184182
    185183            return $associator;
     
    202200         */
    203201        public function ai_suggestions_display(){
    204             $associator = get_site_option( 'wootomation-associator' );
    205 
    206             if( !$associator ) return false;
    207 
     202            $associator = get_option( 'wootomation-associator' );
     203           
    208204            require __DIR__ . '/includes/class-ai.php';
    209 
    210             $rules = Wootomation_AI::get_rules($associator);
    211 
    212205            require __DIR__ . '/includes/class-sales.php';
    213 
     206           
    214207            // get all products in cart
    215208            $products_in_cart = Wootomation_Sales::get_cart_items();
    216 
    217             // get all combinations of products
    218             $all_combinations = Wootomation_Sales::get_combinations($products_in_cart);
    219 
     209               
    220210            // get all suggestions based off all combinations
    221211            $suggestions = array();
    222212           
    223             foreach ($all_combinations as $combination) {
    224                 // for each combination AI predict 
    225                 $prediction = Wootomation_AI::predict($associator, $combination);
    226                 // add prediction to suggestions array
    227                 foreach ($prediction as $predict) {
    228                     $suggestions[] = $predict;
     213
     214            if( $associator ){
     215
     216                $rules = Wootomation_AI::get_rules($associator);
     217
     218
     219                // get all combinations of products
     220                $all_combinations = Wootomation_Sales::get_combinations($products_in_cart);
     221               
     222                foreach ($all_combinations as $combination) {
     223                    // for each combination AI predict 
     224                    $prediction = Wootomation_AI::predict($associator, $combination);
     225                    // add prediction to suggestions array
     226                    foreach ($prediction as $predict) {
     227                        $suggestions[] = $predict;
     228                    }
    229229                }
    230230            }
     
    269269                    'post_status'    => 'publish',
    270270                    'posts_per_page' => $needed_sugestions,
     271                    'post__not_in'   => $products_in_cart,
    271272                    'tax_query' => array(
    272273                        array (
Note: See TracChangeset for help on using the changeset viewer.