Plugin Directory

Changeset 1445623


Ignore:
Timestamp:
06/29/2016 10:14:13 AM (10 years ago)
Author:
cueteam
Message:

Added 'set price alert' button, Improved sync, Fixed screenshots location

Location:
cue-connect
Files:
7 added
3 edited

Legend:

Unmodified
Added
Removed
  • cue-connect/trunk/cue-connect.php

    r1351273 r1445623  
    22/**
    33 * Plugin Name: Cue Connect
    4  * Plugin URI: Http://
    54 * Description: Meet Cue, your customers’ personal shopping assistant that feeds you actionable data.
    6  * Version: 1.0
     5 * Version: 1.0.1
    76 * Author: WooThemes
    87 * Author URI: http://woothemes.com/
     
    1110 * Text Domain: cue-connect
    1211 *
    13  * Copyright: © 2009-2015 WooThemes.
     12 * Copyright: © 2009-2016 WooThemes.
    1413 * License: GNU General Public License v3.0
    1514 * License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    4140    require_once( CUE__PLUGIN_DIR . 'inc/class.cue-rapi-client.php' );
    4241
     42    // Include sync class
     43    require_once( CUE__PLUGIN_DIR . 'inc/class.cue_sync.php');
     44
    4345    // Load the plugin
    4446    add_action( 'plugins_loaded', array( 'cue_connect', 'init' ) );
  • cue-connect/trunk/inc/class.cue-connect.php

    r1351273 r1445623  
    1717            add_filter( 'woocommerce_integrations', array( 'cue_connect', 'add_integration' ) );
    1818        }
    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'));
    2122
    2223        // Add Sharing tools to the product page
     
    4748        $integrations[] = 'Cue_Integration';
    4849        return $integrations;
    49     }
    50 
    51     /**
    52      * Retrieve products from woocommerce database and send them the cue Rapi
    53      */
    54     public static function products_synchronization() {
    55         // Make sure the settings are defined
    56         if ( $settings = get_option( 'woocommerce_cue_settings' ) ) {
    57             // Load cue rapi client
    58             $cue_client = new Cue_Rapi_Client( $settings['username'], $settings['password'] );
    59             // Query arguments
    60             $args = array(
    61                 'post_type'      => 'product',
    62                 'posts_per_page' => 10,
    63             );
    64             // Last synchronization date
    65             $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 database
    76             $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 specifications
    85                 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 cue
    95                     $payload = array( 'data' => $cue_products );
    96                     $response = $cue_client->sync_products( $payload );
    97                     if ( ! $response || ! $response->status ) {
    98                         $error = true;
    99                     }
    100                 }
    101                 // Next page
    102                 $page++;
    103             }
    104             // Save current date as last synchronization
    105             if ( ! $error ) {
    106                 update_option( 'woocommerce_cue_last_sync', $current_sync );
    107             }
    108         }
    109     }
    110 
    111     /**
    112      * Format WC_Product object
    113      * @param  WC_Product $wc_product
    114      * @return array
    115      */
    116     public static function convert_to_cue_product( $wc_product ) {
    117         // Grab the categories of the product
    118         if ( ! $categories = wp_get_post_terms( $wc_product->get_post_data()->ID, 'product_cat', array( 'fields' => 'names' ) ) ) {
    119             $categories[0] = '';
    120         }
    121         // Return formatted data
    122         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 category
    130         );
    13150    }
    13251
  • cue-connect/trunk/readme.txt

    r1394219 r1445623  
    33Tags: 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
    44Requires at least: 3.8
    5 Tested up to: 4.2
     5Tested up to: 4.5.3
    66WC requires at least: 2.2
    77WC tested up to: 2.4
    8 Stable tag: 1.0
     8Stable tag: 1.0.1
    99License: GPLv3 or later License
    1010License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    59592. Upload Cue plugin zip file through the Admin panel.
    60603. Activate the plugin through the "Plugins" menu in WordPress.
    61 4. Create an account on Cue Connect.
     614. Fill your Cue Connect account data in Woocommerce->Settings->Integrations->Cue Connect
    62625. Add My Cue widget to your site.
    6363
     
    7676== Changelog ==
    7777
     78= 1.0.1 =
     79* Added 'price alert' button to product page
     80* Improved products synchronization
     81
    7882= 1.0 =
    7983* Launch!
Note: See TracChangeset for help on using the changeset viewer.