Changeset 1445623
- Timestamp:
- 06/29/2016 10:14:13 AM (10 years ago)
- Location:
- cue-connect
- Files:
-
- 7 added
- 3 edited
-
assets/1.sharing-widget.png (added)
-
assets/10.overview.png (added)
-
assets/2.cue-box.png (added)
-
assets/3.cue-wall.png (added)
-
assets/4.on-site-convo.png (added)
-
assets/5.reporting-suite.png (added)
-
trunk/cue-connect.php (modified) (3 diffs)
-
trunk/inc/class.cue-connect.php (modified) (2 diffs)
-
trunk/inc/class.cue-sync.php (added)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cue-connect/trunk/cue-connect.php
r1351273 r1445623 2 2 /** 3 3 * Plugin Name: Cue Connect 4 * Plugin URI: Http://5 4 * Description: Meet Cue, your customers’ personal shopping assistant that feeds you actionable data. 6 * Version: 1.0 5 * Version: 1.0.1 7 6 * Author: WooThemes 8 7 * Author URI: http://woothemes.com/ … … 11 10 * Text Domain: cue-connect 12 11 * 13 * Copyright: © 2009-201 5WooThemes.12 * Copyright: © 2009-2016 WooThemes. 14 13 * License: GNU General Public License v3.0 15 14 * License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 41 40 require_once( CUE__PLUGIN_DIR . 'inc/class.cue-rapi-client.php' ); 42 41 42 // Include sync class 43 require_once( CUE__PLUGIN_DIR . 'inc/class.cue_sync.php'); 44 43 45 // Load the plugin 44 46 add_action( 'plugins_loaded', array( 'cue_connect', 'init' ) ); -
cue-connect/trunk/inc/class.cue-connect.php
r1351273 r1445623 17 17 add_filter( 'woocommerce_integrations', array( 'cue_connect', 'add_integration' ) ); 18 18 } 19 // Create the hook for product synchronization 20 add_action( 'cue_sync_hook', array( 'cue_connect', 'products_synchronization' ), 100 ); 19 // Create the hooks for product synchronization 20 add_action( 'cue_sync_hook', array( 'cue_sync', 'start_sync' ), 100 ); 21 add_action( 'wp_ajax_nopriv_cue_sync_slice', array('cue_sync', 'ajax_cue_sync_slice')); 21 22 22 23 // Add Sharing tools to the product page … … 47 48 $integrations[] = 'Cue_Integration'; 48 49 return $integrations; 49 }50 51 /**52 * Retrieve products from woocommerce database and send them the cue Rapi53 */54 public static function products_synchronization() {55 // Make sure the settings are defined56 if ( $settings = get_option( 'woocommerce_cue_settings' ) ) {57 // Load cue rapi client58 $cue_client = new Cue_Rapi_Client( $settings['username'], $settings['password'] );59 // Query arguments60 $args = array(61 'post_type' => 'product',62 'posts_per_page' => 10,63 );64 // Last synchronization date65 $last_sync = get_option( 'woocommerce_cue_last_sync', false );66 $current_sync = date( 'r' );67 if ( $last_sync ) {68 $args['date_query'] = array(69 array(70 'column' => 'post_modified_gmt',71 'after' => $last_sync,72 ),73 );74 }75 // Retrieve the products from the database76 $query = new WP_Query( $args );77 $max_page = $query->max_num_pages;78 $page = 1;79 $error = false;80 while ( $page <= $max_page ) {81 $args['paged'] = $page;82 $query = ( 1 === $page ) ? $query : new WP_Query( $args );83 $cue_products = array();84 // Format the data to comply with the rapi specifications85 if ( $query->have_posts() ) {86 while ( $query->have_posts() ) {87 $query->the_post();88 $cue_products[] = self::convert_to_cue_product( new WC_Product( get_the_ID() ) );89 }90 }91 wp_reset_postdata();92 93 if ( ! empty( $cue_products ) ) {94 // Send the products data to cue95 $payload = array( 'data' => $cue_products );96 $response = $cue_client->sync_products( $payload );97 if ( ! $response || ! $response->status ) {98 $error = true;99 }100 }101 // Next page102 $page++;103 }104 // Save current date as last synchronization105 if ( ! $error ) {106 update_option( 'woocommerce_cue_last_sync', $current_sync );107 }108 }109 }110 111 /**112 * Format WC_Product object113 * @param WC_Product $wc_product114 * @return array115 */116 public static function convert_to_cue_product( $wc_product ) {117 // Grab the categories of the product118 if ( ! $categories = wp_get_post_terms( $wc_product->get_post_data()->ID, 'product_cat', array( 'fields' => 'names' ) ) ) {119 $categories[0] = '';120 }121 // Return formatted data122 return array(123 'sku' => $wc_product->get_post_data()->ID,124 'price' => $wc_product->get_price(),125 'name' => $wc_product->get_title(),126 'description' => $wc_product->get_post_data()->post_content,127 'url' => $wc_product->get_permalink(),128 'icon' => wp_get_attachment_url( $wc_product->get_image_id() ),129 'product_type' => $categories[0], // Use the first category130 );131 50 } 132 51 -
cue-connect/trunk/readme.txt
r1394219 r1445623 3 3 Tags: social, sharing, Social sharing, facebook, twitter, pinterest, tumbler, email, analytics, data, post, save, wish list, cue, cue connect, cue wall, cue box, smart widget, easy implementation 4 4 Requires at least: 3.8 5 Tested up to: 4. 25 Tested up to: 4.5.3 6 6 WC requires at least: 2.2 7 7 WC tested up to: 2.4 8 Stable tag: 1.0 8 Stable tag: 1.0.1 9 9 License: GPLv3 or later License 10 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 59 59 2. Upload Cue plugin zip file through the Admin panel. 60 60 3. Activate the plugin through the "Plugins" menu in WordPress. 61 4. Create an account on Cue Connect.61 4. Fill your Cue Connect account data in Woocommerce->Settings->Integrations->Cue Connect 62 62 5. Add My Cue widget to your site. 63 63 … … 76 76 == Changelog == 77 77 78 = 1.0.1 = 79 * Added 'price alert' button to product page 80 * Improved products synchronization 81 78 82 = 1.0 = 79 83 * Launch!
Note: See TracChangeset
for help on using the changeset viewer.