Changeset 2176233
- Timestamp:
- 10/19/2019 10:45:42 PM (6 years ago)
- Location:
- wootomation/trunk
- Files:
-
- 4 edited
-
includes/class-admin.php (modified) (5 diffs)
-
includes/class-ai.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
wootomation.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wootomation/trunk/includes/class-admin.php
r2176202 r2176233 6 6 * 7 7 * @package Wootomation 8 * @version 1.1. 08 * @version 1.1.2 9 9 */ 10 10 … … 31 31 <form method="post" action="options.php"> 32 32 <?php settings_fields( 'wootomation-settings' ); ?> 33 <?php settings_fields( 'wootomation-locations' ); ?>33 <?php //settings_fields( 'wootomation-locations' ); ?> 34 34 <?php do_settings_sections( 'woocommerce' ); ?> 35 35 <?php submit_button(); ?> … … 41 41 // Register settings 42 42 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' ); 45 45 46 46 // Register sections 47 47 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' ); 49 49 50 50 // Register fields 51 51 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' ); 54 54 } 55 55 … … 63 63 64 64 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') ); 66 66 echo '<input type="number" name="wootomation_suggestions_per_page" value="'.$option.'" placeholder="3" />'; 67 67 } 68 68 69 69 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') ); 71 71 $html = '<label class="switch">'; 72 72 $html .= '<input type="checkbox" name="wootomation_after_cart_table" value="1"' . checked( 1, $option, false ) . '/>'; … … 77 77 78 78 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') ); 80 80 echo '<input type="text" name="wootomation_after_cart_table_title" value="'.$option.'" placeholder="People who bought this, also bought…" class="regular-text" />'; 81 81 } -
wootomation/trunk/includes/class-ai.php
r2176195 r2176233 6 6 * 7 7 * @package Wootomation 8 * @version 1.1. 08 * @version 1.1.2 9 9 */ 10 10 -
wootomation/trunk/readme.txt
r2176202 r2176233 39 39 == Changelog == 40 40 41 = 1.1.2 = 42 * Fixed admin page bug. 43 41 44 = 1.1.1 = 42 * Added multisite support.45 * Improved multisite support. 43 46 44 47 = 1.1.0 = … … 55 58 == Upgrade Notice == 56 59 60 = 1.1.2 = 61 * Fixed admin page bug. 62 57 63 = 1.1.1 = 58 Added multisite support.64 Improved multisite support. 59 65 60 66 = 1.1.0 = -
wootomation/trunk/wootomation.php
r2176205 r2176233 4 4 * Plugin URI: https://wordpress.org/support/plugin/wootomation/ 5 5 * 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. 17 * Stable tag: 1.1. 16 * Version: 1.1.2 7 * Stable tag: 1.1.2 8 8 * Author: Dragos Micu 9 9 * Author URI: https://wordpress.org/support/users/dragosmicu/ … … 32 32 $this->plugin_name = plugin_basename( __FILE__ ); 33 33 $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') ); 36 36 $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…",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…", 38 38 )); 39 39 … … 81 81 public function deactivate() { 82 82 flush_rewrite_rules(); 83 delete_site_option( 'wt-donate' );84 delete_site_option( 'wt-hide-review' );85 83 } 86 84 … … 111 109 if( !get_site_transient( 'wt-admin-notices-after-one-month' ) ){ 112 110 // 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' ) ) { 114 112 // then check for "Dismiss" GET request 115 113 if( isset( $_GET['wt-hide-review'] ) ): 116 114 // If GET request to hide notice exists, add option 117 115 if( $_GET['wt-hide-review'] === 'true' ): 118 add_ site_option('wt-hide-review', 'true');116 add_option('wt-hide-review', 'true'); 119 117 endif; 120 118 // If GET request doesn't exist, continue displaying notice … … 130 128 if( !get_site_transient( 'wt-admin-notices-after-two-months' ) ){ 131 129 // check if wt-donate option doesn't exist 132 if( false === get_ site_option( 'wt-donate' ) ) {130 if( false === get_option( 'wt-donate' ) ) { 133 131 // then check for "Dismiss" GET request 134 132 if( isset( $_GET['wt-donate'] ) ): 135 133 // If GET request to hide notice exists, add option 136 134 if( $_GET['wt-donate'] === 'true' ): 137 add_ site_option('wt-donate', 'true');135 add_option('wt-donate', 'true'); 138 136 endif; 139 137 // If GET request doesn't exist, continue displaying notice … … 181 179 $associator = Wootomation_AI::train($sales); 182 180 183 update_ option( 'wootomation-associator', $associator );181 update_site_option( 'wootomation-associator', $associator ); 184 182 185 183 return $associator; … … 202 200 */ 203 201 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 208 204 require __DIR__ . '/includes/class-ai.php'; 209 210 $rules = Wootomation_AI::get_rules($associator);211 212 205 require __DIR__ . '/includes/class-sales.php'; 213 206 214 207 // get all products in cart 215 208 $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 220 210 // get all suggestions based off all combinations 221 211 $suggestions = array(); 222 212 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 } 229 229 } 230 230 } … … 269 269 'post_status' => 'publish', 270 270 'posts_per_page' => $needed_sugestions, 271 'post__not_in' => $products_in_cart, 271 272 'tax_query' => array( 272 273 array (
Note: See TracChangeset
for help on using the changeset viewer.