Plugin Directory

Changeset 1128309


Ignore:
Timestamp:
04/05/2015 07:38:28 PM (11 years ago)
Author:
2kblater.com
Message:

v2.0.0 BETA 3

Location:
2kb-amazon-affiliates-store/trunk
Files:
3 added
16 edited

Legend:

Unmodified
Added
Removed
  • 2kb-amazon-affiliates-store/trunk/KbAmazonController.php

    r1122895 r1128309  
    3030        add_action('wp_ajax_kbAmzLoadItemPreview', array($this, 'kbAmzLoadItemPreviewAction'));
    3131        add_action('wp_ajax_kbAmzImportItem', array($this, 'kbAmzImportItemAjaxAction'));
     32        add_action('wp_ajax_kbAmzNetworkMembers', array($this, 'networkMembersAction'));
     33        add_action('wp_ajax_kbAmzNetworkGetProductsToSync', array($this, 'kbAmzNetworkGetProductsToSyncAction'));
     34        add_action('wp_ajax_kbAmzNetworkImportProduct', array($this, 'kbAmzNetworkImportProductAction'));
     35       
     36       
    3237    }
    3338   
     
    601606        return $view;
    602607    }
     608   
     609    public function kbAmzNetworkImportProductAction()
     610    {
     611        $response = array();
     612        try {
     613            $imported = [];
     614            foreach ($_POST['items'] as $itemData) {
     615                $item = unserialize(base64_decode($itemData['item']));
     616                $importer = new KbAmazonImporter;
     617                $importer->updateProductPrice($item);
     618                $imported[] = array(
     619                    'asin' => $itemData['asin']
     620                );
     621            }
     622           
     623            $response['items']   = $imported;
     624            $response['success'] = true;
     625        } catch (Exception $e) {
     626            $response['success'] = false;
     627            $response['error']   = $e->getMessage();
     628            getKbAmz()->addException('Newtwork Product Fetch', $e->getMessage());
     629           
     630        }
     631        echo json_encode($response);
     632        die;
     633    }
     634
     635   
     636    public function kbAmzNetworkGetProductsToSyncAction()
     637    {
     638        $asins      = getKbAmz()->getProductsAsinsToUpdate(50);
     639        $products   = array();
     640        foreach ($asins as $asin) {
     641            $products[$asin] = getKbAmz()->getProductByAsin($asin);
     642        }
     643        $sizes = get_intermediate_image_sizes();
     644        $size = 'thumbnail';
     645        if (in_array('small', $sizes)) {
     646            $size = 'small';
     647        } else if (in_array('medium', $sizes)) {
     648            $size = 'medium';
     649        }
     650       
     651        $view = new KbView(array());
     652        $view->setTemplate($this->getTemplatePath('kbAmzNetworkGetProductsToSync'));
     653        $view->products = $products;
     654        $view->size     = $size;
     655        echo $view;
     656        die;
     657    }
     658
     659    public function networkMembersAction()
     660    {
     661       
     662        $api = new KbAmzApi(getKbAmz()->getStoreId());
     663        $result =  $api->getNetworkListHtml();
     664        if ($result->error) {
     665            $data             = array();
     666            $data['page']     = 'kbAmz';
     667            $data['kbAction'] = 'network';
     668            echo '<div role="alert" class="alert alert-danger">Unable to connect to the service server. <a href="?'.  http_build_query($data).'">Please reload the page</a>.</div>';
     669        } else {
     670            echo $result->content;
     671        }
     672        die;
     673    }
     674
     675    public function networkAction()
     676    {
     677        $data         = array();
     678        $user         = wp_get_current_user();
     679        $data['user'] = wp_get_current_user();
     680        $data['siteOwnerName'] = $user->data->display_name;
     681        if (isset($user->data->first_name)
     682        && !empty($user->data->first_name)
     683        && isset($user->data->last_name)
     684        && !empty($user->data->last_name)) {
     685            $data['siteOwnerName'] = sprintf(
     686                '%s %s',
     687                $user->data->first_name,
     688                $user->data->last_name
     689            );
     690        }
     691       
     692        $data['siteOwnerEmail']  = $user->data->user_email;
     693        $data['siteName']        = get_bloginfo('name');
     694        $data['siteUrl']         = get_bloginfo('url');
     695        $data['siteInfo']        = get_bloginfo('description');
     696
     697        if (isset($_POST['submit'])) {
     698           
     699            $data  =
     700            array(
     701                'siteOwnerName'     => empty($_POST['siteOwnerName'])   ? $data['siteOwnerName']    : $_POST['siteOwnerName'],
     702                'siteOwnerEmail'    => empty($_POST['siteOwnerEmail'])  ? $data['siteOwnerEmail']   : $_POST['siteOwnerEmail'],
     703                'siteName'          => empty($_POST['siteName'])        ? $data['siteName']         : $_POST['siteName'],
     704                'siteUrl'           => empty($_POST['siteUrl'])         ? $data['siteUrl']          : $_POST['siteUrl'],
     705                'siteInfo'          => substr(empty($_POST['siteInfo'])        ? $data['siteInfo']         : $_POST['siteInfo'], 0, 250),
     706                'siteActive'        => $_POST['submit'] == 'join',
     707                'siteHealth'        => getKbAmzStoreHealth()
     708            );
     709           
     710            getKbAmz()->setOption('siteNetwork', $data);
     711           
     712            $api = new KbAmzApi(getKbAmz()->getStoreId());
     713            $result =  $api->setUser($data);
     714           
     715            if (isset($result->error) && $result->error) {
     716                $this->messages[] = array('Unable to join the 2kb Amazon Network at this time. Error: ' .$result->error, 'alert-warning');
     717            } else {
     718                if ($_POST['submit'] == 'join') {
     719                    $this->messages[] = array('You successfully <b>joined</b> 2kb Amazon Network', 'alert-success');
     720                } else {
     721                    $this->messages[] = array('You successfully <b>left</b> 2kb Amazon Network', 'alert-danger');
     722                }
     723            }
     724        } else {
     725            $siteNetwork = getKbAmz()->getOption('siteNetwork');
     726            if (!empty($siteNetwork)) {
     727                $data = $siteNetwork;
     728            }
     729        }
     730       
     731         
     732        $data['canLeave'] = isset($data['siteActive']) && $data['siteActive'];
     733       
     734        $view = new KbView($data);
     735        return $view;
     736    }
     737
     738    public function shortCodeProductAction($atts)
     739    {
     740        $post = null;
     741        if ($atts['asin']) {
     742            $post = getKbAmz()->getProductByAsin($atts['asin']);
     743            if (!$post) {
     744                $_POST['asin'] = $atts['asin'];
     745                $this->importByAsinAction();
     746            }
     747            $post = getKbAmz()->getProductByAsin($atts['asin']);
     748        } else {
     749            $post = get_post($atts['postId']);
     750        }
     751       
     752        if (!$post) {
     753            throw new Exception('Invalid product, check postId or asin');
     754        }
     755        $atts['post'] = $post;
     756        $atts['meta'] = getKbAmz()->getProductMeta($post->ID);
     757        $view = new KbView($atts);
     758        $view->setTemplate($this->getTemplatePath('shortCodeProduct'));
     759        return $view;
     760    }
    603761
    604762    protected function getActions() {
  • 2kb-amazon-affiliates-store/trunk/KbAmazonImporter.php

    r1122895 r1128309  
    390390    }
    391391
    392     /**
     392    public function getResponseGroup()
     393    {
     394        return
     395        array(
     396            'Large',
     397            'Offers',
     398            'OfferFull',
     399            'OfferSummary',
     400            'OfferListings',
     401            'PromotionSummary',
     402            'Variations',
     403            'VariationImages',
     404            'VariationSummary',
     405            'VariationMatrix',
     406            'VariationOffers',
     407            'ItemAttributes',
     408            'Accessories',
     409            'EditorialReview',
     410            'SalesRank',
     411            'BrowseNodes',
     412            'Images',
     413            'Similarities',
     414            'Reviews',
     415            'SearchInside',
     416            'PromotionalTag',
     417            'AlternateVersions',
     418            'Collections',
     419            'ShippingCharges',
     420            //'RelatedItems',
     421            // No access
     422            //'ShippingOptions',
     423        );
     424    }
     425
     426        /**
    393427     *
    394428     * @param str $asin
     
    398432    {
    399433        if (!$responseGroup) {
    400             $responseGroup = array(
    401                 'Large',
    402                 'Offers',
    403                 'OfferFull',
    404                 'OfferSummary',
    405                 'OfferListings',
    406                 'PromotionSummary',
    407                 'Variations',
    408                 'VariationImages',
    409                 'VariationSummary',
    410                 'VariationMatrix',
    411                 'VariationOffers',
    412                 'ItemAttributes',
    413                 'Accessories',
    414                 'EditorialReview',
    415                 'SalesRank',
    416                 'BrowseNodes',
    417                 'Images',
    418                 'Similarities',
    419                 'Reviews',
    420                 'SearchInside',
    421                 'PromotionalTag',
    422                 'AlternateVersions',
    423                 'Collections',
    424                 'ShippingCharges',
    425                 //'RelatedItems',
    426                 // No access
    427                 //'ShippingOptions',
    428             );
     434            $responseGroup = $this->getResponseGroup();
    429435        } else {
    430436            $responseGroup = is_array($responseGroup) ? $responseGroup : array($responseGroup);
     
    449455                $result = getKbAmazonApi()
    450456                          ->responseGroup(implode(',', $responseGroup))
    451                           ->optionalParameters(array('MerchantId' => 'All'))
    452457                          ->lookup($asin);
    453                
    454458            } catch (Exception $e) {
    455459                if ($sleep) {
     
    585589        $meta['PriceAmountFormatted'] = 0;
    586590       
    587 //        if (isset($meta['Offers.Offer.OfferListing.Price.FormattedPrice'])) {
    588 //            $meta['PriceAmount']          = $meta['Offers.Offer.OfferListing.Price.Amount'];
    589 //            $meta['PriceAmountFormatted'] = $meta['Offers.Offer.OfferListing.Price.FormattedPrice'];
    590 //        } else {
    591 //            $sort = array();
    592 //            foreach ($this->pricePairs as $pair) {
    593 //                if (isset($meta[$pair[0]])
    594 //                && isset($meta[$pair[1]])) {
    595 //                    $sort[] = array(
    596 //                        'PriceAmountFormatted'  => $meta[$pair[0]],
    597 //                        'PriceAmount'           => $meta[$pair[1]],
    598 //                        'order'                 => $meta[$pair[1]],
    599 //                    );
    600 //                }
    601 //            }
    602 //            if (!empty($sort)) {
    603 //                usort($sort, 'kbAmzSortOrder');
    604 //                $pair = $sort[key($sort)];
    605 //                $meta['PriceAmount']          = $pair['PriceAmount'];
    606 //                $meta['PriceAmountFormatted'] = $pair['PriceAmountFormatted'];
    607 //            }
    608 //        }
    609         /**
    610          * Old version
    611          */
    612         if (isset($meta['Offers.Offer.OfferListing.Price.FormattedPrice'])) {
     591        //1. OfferSummary.LowestNewPrice.FormattedPrice
     592        //2. Offers.Offer.OfferListing.SalePrice.FormattedPrice
     593        //3. Offers.Offer.OfferListing.Price.FormattedPrice
     594        //4. ItemAttributes.ListPrice.FormattedPrice
     595       
     596        if (isset($meta['Offers.Offer.OfferListing.SalePrice.FormattedPrice'])) {
     597            $meta['PriceAmountFormatted'] = $meta['Offers.Offer.OfferListing.SalePrice.FormattedPrice'];
     598            $meta['PriceAmount']          = $meta['Offers.Offer.OfferListing.SalePrice.Amount'];
     599        } else if (isset($meta['OfferSummary.LowestNewPrice'])) {
     600            $meta['PriceAmountFormatted'] = $meta['OfferSummary.LowestNewPrice.FormattedPrice'];
     601            $meta['PriceAmount']          = $meta['OfferSummary.LowestNewPrice.Amount'];
     602        } else if (isset($meta['Offers.Offer.OfferListing.Price'])) {
     603            $meta['PriceAmountFormatted'] = $meta['Offers.Offer.OfferListing.Price.FormattedPrice'];
     604            $meta['PriceAmount']          = $meta['Offers.Offer.OfferListing.Price.Amount'];
     605        } else if (isset($meta['ItemAttributes.ListPrice.FormattedPrice'])) {
     606            $meta['PriceAmountFormatted'] = $meta['ItemAttributes.ListPrice.FormattedPrice'];
     607            $meta['PriceAmount']          = $meta['ItemAttributes.ListPrice.Amount'];
     608        } else if (isset($meta['Offers.Offer.OfferListing.Price.FormattedPrice'])) {
     609            /**
     610             * @TODO CHECK BELOW!
     611             */
    613612            $meta['PriceAmount']          = $meta['Offers.Offer.OfferListing.Price.Amount'];
    614613            $meta['PriceAmountFormatted'] = $meta['Offers.Offer.OfferListing.Price.FormattedPrice'];
     
    629628            $meta['PriceAmount'] = $meta['OfferSummary.LowestCollectiblePrice.Amount'];
    630629        }
    631        
     630
    632631        $meta['PriceAmount'] = self::paddedNumberToDecial($meta['PriceAmount']);
    633632    }
     
    651650
    652651
    653     public function saveProduct(KbAmazonItem $item, $isSimilar = false)
     652    public function saveProduct(KbAmazonItem $item, $isSimilar = false, $disableEvents = false)
    654653    {
    655654        $postExists = $this->itemExists($item);
     
    660659        $std->item          = $item;
    661660       
    662         do_action('KbAmazonImporter::preSaveProduct', $std);
     661        if (!$disableEvents) {
     662            do_action('KbAmazonImporter::preSaveProduct', $std);
     663        }
    663664       
    664665        $postExists         = $std->postId;
     
    807808        $std->importer    = $this;
    808809        $std->postExists  = $postExists;
    809        
    810         do_action('KbAmazonImporter::saveProduct', $std);
     810        if (!$disableEvents) {
     811            do_action('KbAmazonImporter::saveProduct', $std);
     812        }
    811813       
    812814        return array(
  • 2kb-amazon-affiliates-store/trunk/KbAmazonStore.php

    r1122895 r1128309  
    108108            ),
    109109            'active' => false,
    110         )
     110        ),
     111        'product' => array(
     112            'code' => 'kb_amz_product',
     113            'params' => array(
     114                ''              => '<span class="label label-success">NEW</span>',
     115                'asin'          => 'Use asin or post id',
     116                'ID'            => 'Use post id or asin'
     117            ),
     118            'active' => null,
     119        ),
    111120    );
    112121
  • 2kb-amazon-affiliates-store/trunk/KbAmzOptions.php

    r1122895 r1128309  
    3737        */
    3838       'KbAmzV2VariantsMessageSeen'         => false,
     39       'AttributesCountMessageSeen'         => false,
    3940   );
    4041   
  • 2kb-amazon-affiliates-store/trunk/lib/KbAmazonItem.php

    r1122895 r1128309  
    5555       
    5656        $isValid = false;
    57         if (!isset($this->item['ItemAttributes']['Title'])
    58         ||  !isset($this->item['ASIN'])) {
     57        if (!isset($this->item['ASIN'])) {
    5958           $isValid = false;
    6059        } else {
  • 2kb-amazon-affiliates-store/trunk/lib/kbAmzApi.php

    r1118181 r1128309  
    66    const PRODUCTS_CATEGORY = 86;
    77   
    8     protected $apiKey = null;
     8    protected $apiKey   = null;
     9    protected $apiKey2  = null;
     10
     11
     12    public function __construct()
     13    {
     14        $this->apiKey   = getKbAmz()->getStoreId();
     15
     16    }
    917   
    10     public function __construct($apiKey)
     18    public function setUser($data)
    1119    {
    12         $this->apiKey = $apiKey;
     20        return $this->getRequest('setUser', $data);
    1321    }
    1422
     
    2230    {
    2331        return $this->getRequest('getProductsListHtml');
     32    }
     33   
     34    public function getNetworkListHtml()
     35    {
     36        return $this->getRequest('getNetworkListHtml');
    2437    }
    2538   
     
    3750    {
    3851        $params['2kbProductsApiAction'] = $action;
    39         $params['cat'] = self::PRODUCTS_CATEGORY;
    40         $params['type'] = 'json';
    41         $params['apiType'] = 'kbAmz';
    42         $params['apiKey'] = $this->apiKey;
     52        $params['cat']                  = self::PRODUCTS_CATEGORY;
     53        $params['type']                 = 'json';
     54        $params['apiType']              = 'kbAmz';
     55        $params['apiKey']               = $this->apiKey;
     56        $params['requestTime']          = date('Y-m-d H:i:s');
    4357       
    4458        $requestUrl = sprintf(
     
    4660            http_build_query($params)
    4761        );
    48         //echo $requestUrl;die;
    49         $content = file_get_contents($requestUrl);
     62       
     63        $response = wp_remote_get($requestUrl);
     64        $content  = '';
     65        if (isset($response['body'])) {
     66            $content = $response['body'];
     67        }
    5068        $data = array();
    5169        if (!empty($content)) {
  • 2kb-amazon-affiliates-store/trunk/plugin.php

    r1122895 r1128309  
    44 * Plugin URI: http://www.2kblater.com/?p=8318
    55 * Description: Amazon Affiliate Store Plugin With Variants, Cart, Checkout, Custom Themes, Variants and Versions. Easy to manage and setup. Sell wide range of physical and digital products imported from Amazon Affiliate API using 90 days cookie reference. This plugin is released with GPL2 license.
    6  * Version: 2.0.0 BETA 2
     6 * Version: 2.0.0 BETA 3
    77 * Author: 2kblater.com
    88 * Author URI: http://www.2kblater.com
     
    1616}
    1717
    18 define('KbAmazonVersion', '2.0.0 BETA 2');
     18define('KbAmazonVersion', '2.0.0 BETA 3');
    1919define('KbAmazonVersionNumber', 200);
    2020define('KbAmazonStoreFolderName',  pathinfo(dirname(__FILE__), PATHINFO_FILENAME));
  • 2kb-amazon-affiliates-store/trunk/readme.txt

    r1122895 r1128309  
    3737
    3838== Changelog ==
     39= 2.0.0 BETA 3=
     40Product Short Code added
     41Prices Fixed
     42Store Sync Health added
     43Layout Update
    3944= 2.0.0 BETA 2=
    4045New Import loaded, custom categories are now working.
  • 2kb-amazon-affiliates-store/trunk/store_functions.php

    r1119725 r1128309  
    484484    return $output;
    485485}
     486
     487function getKbAmzStoreHealth()
     488{
     489    $hours = 0;
     490    $count = getKbAmz()->getProductsToUpdateCount();
     491    if ($count > 0) {
     492        $per = getKbAmz()->getOption('updateProductsPriceCronNumberToProcess');
     493        $interval = getKbAmz()->getOption('updateProductsPriceCronInterval');
     494        $intervals = $count / $per;
     495        $intervalHours = 1;
     496        if ($interval == 'twicedaily') {
     497            $intervalHours = 12;
     498        } else if ($interval == 'daily') {
     499            $intervalHours = 24;
     500        }
     501        $hours = ceil($intervals . $intervalHours);
     502    }
     503   
     504    $h = round(($hours / 24) * 100);
     505    return $h;
     506}
     507
     508function getKbAmzStoreHealthHtml()
     509{
     510    $health = getKbAmzStoreHealth();
     511    $class = 'danger';
     512    if ($health > 80 && $health <= 100) {
     513        $class = 'success';
     514    } else if ($health > 50 && $health <= 100) {
     515        $class = 'warning';
     516    }
     517    $percent = $health > 100 ? 100 : $health;
     518    ob_start();
     519    ?>
     520    <div class="progress">
     521        <div class="progress-bar progress-bar-<?php echo $class;?>" style="width: <?php echo $percent; ?>%;">
     522          <?php echo $health; ?>%
     523        </div>
     524    </div>
     525    <?php
     526    return ob_get_clean();
     527}
  • 2kb-amazon-affiliates-store/trunk/store_init.php

    r1122895 r1128309  
    2323 * CRONS
    2424 */
     25if (!wp_next_scheduled('kbAmzSyncNetwork') ) {
     26    wp_schedule_event(
     27        time(),
     28        86400,
     29        'kbAmzSyncNetwork'
     30    );
     31}
     32add_action('kbAmzSyncNetwork', 'kbAmzSyncNetworkFunction');
     33
     34function kbAmzSyncNetworkFunction()
     35{
     36    $data = getKbAmz()->getOption('siteNetwork');
     37    if (!empty($data) && $data['siteActive']) {
     38        $api = new KbAmzApi(getKbAmz()->getStoreId());
     39        $data['siteHealth'] = getKbAmzStoreHealth();
     40        $api->setUser($data);
     41    }
     42}
     43
    2544if (!wp_next_scheduled('kbAmzDownloadProductsCron') ) {
    2645    wp_schedule_event(
     
    3049    );
    3150}
    32 
    3351add_action('kbAmzDownloadProductsCron', 'kbAmzDownloadProductsCronFunction');
    3452
     
    151169    }
    152170}
    153 
    154 
    155171
    156172
     
    311327    return $query;
    312328}
     329
     330
     331if (isset($_GET['kbAction'])
     332&& $_GET['kbAction'] == 'KbAmzNetworkGetProduct'
     333&& isset($_GET['asin'])) {
     334   
     335    add_action('init', 'kbAmzTriggerManualUpdateCronJobs');
     336    function kbAmzTriggerManualUpdateCronJobs()
     337    {
     338        $response = array();
     339        $asin     = $_GET['asin'];
     340        $responseGroup = array(
     341            'Offers',
     342            'OfferFull',
     343            'OfferSummary',
     344            'OfferListings',
     345        );
     346        try {
     347            $importer = new KbAmazonImporter;
     348            $result = getKbAmazonApi()
     349                      ->responseGroup(implode(',', $responseGroup))
     350                      ->lookup($asin);
     351            $item   = new KbAmazonItem($result);
     352            $response['item']    = $item->isValid() ? base64_encode(serialize($item)) : null;
     353            $response['success'] = $item->isValid();
     354        } catch (Exception $e) {
     355            $response['success'] = false;
     356            $response['error']   = $e->getMessage();
     357            getKbAmz()->addException('Newtwork Product Fetch', $e->getMessage());
     358        }
     359        echo sprintf(
     360            ';%s%s(%s);',
     361            PHP_EOL,
     362            $_GET['callback'],
     363            json_encode($response)
     364        );
     365        http_response_code(200);
     366        die;
     367    }
     368}
  • 2kb-amazon-affiliates-store/trunk/store_shortcodes.php

    r1119725 r1128309  
    11<?php
    22!defined('ABSPATH') and exit;
     3
     4// [kb_amz_product]
     5function kb_amz_product_func($atts)
     6{
     7    $atts = shortcode_atts( array(
     8        'ID' => null,
     9        'asin'   => null,
     10    ), $atts);
     11    $atts['postId'] = $atts['ID'];
     12   
     13    if (!$atts['postId'] && !$atts['asin']) {
     14        return new KbAmzErrorString('[kb_amz_product] - ID or asin parameter is required.');
     15    }
     16   
     17    return getKbAmzAdminController()->shortCodeProductAction($atts);
     18}
     19
     20add_shortcode('kb_amz_product', 'kb_amz_product_func');
    321
    422// [kb_amz_product_attributes]
    523function kb_amz_product_attributes_func($atts) {
    624    $atts = shortcode_atts( array(
    7             'post_id' => get_the_ID()
     25        'postId' => get_the_ID()
    826    ), $atts);
    927       
     
    2745       
    2846       
    29         $meta = getKbAmz()->getProductMeta($atts['post_id']);
     47        $meta = getKbAmz()->getProductMeta($atts['postId']);
    3048        $attributes = getKbAmz()->getShortCodeAttributes();
    3149        $markup = '';
    3250        foreach ($attributes as $attr => $label) {
    3351            if (isset($meta[$attr]) && !empty($meta[$attr])) {
    34                
    35                
    36                 // kb-amz-item-price
    37                
    3852                $markup .= sprintf(
    3953                    $htmlList,
  • 2kb-amazon-affiliates-store/trunk/template/admin/css/default.css

    r1122895 r1128309  
    99#kb-amz-admin{
    1010    padding: 0 20px;
     11    padding-left: 0;
    1112    padding-bottom: 20px;
    1213    min-height: 300px;
     
    124125.icons-actions a
    125126{
     127    position: relative;
    126128    display: inline-block;
    127129    padding: 20px;
     
    141143#kb-amz-admin label{
    142144    max-width: 100%;
    143     min-width: 300px;
    144 }
    145 
    146 .bs-callout {
     145    width: 300px;
     146}
     147
     148.bs-callout
     149{
    147150    border-color: #eee;
    148151    border-image: none;
     
    153156    padding: 5px 10px;
    154157}
    155 .bs-callout-info {
     158.bs-callout-info
     159{
    156160    border-left-color: #1b809e;
    157161}
    158 .bs-callout-info h4 {
     162.bs-callout-info h4
     163{
    159164    color: #1b809e;
    160165}
     166
     167.kb-amz-icon-action-dot
     168{
     169    position: absolute;
     170    top: 5px;
     171    right: 5px;
     172    background: #3c763d;
     173    padding: 10px;
     174    line-height: 0;
     175    font-size: 0;
     176    -webkit-border-radius: 10px;
     177    -moz-border-radius: 10px;
     178    border-radius: 10px;
     179    -webkit-box-shadow: 0px 0px 3px 0px rgba(60,118,61,1);
     180    -moz-box-shadow: 0px 0px 3px 0px rgba(60,118,61,1);
     181    box-shadow: 0px 0px 3px 0px rgba(60,118,61,1);
     182}
     183.kb-amz-icon-action-dot.not-active
     184{
     185    background: #a94442;
     186    -webkit-box-shadow: 0px 0px 3px 0px rgba(169,68,66,1);
     187    -moz-box-shadow: 0px 0px 3px 0px rgba(169,68,66,1);
     188    box-shadow: 0px 0px 3px 0px rgba(169,68,66,1);
     189}
     190#sync-container
     191{
     192    margin-left: -5px;
     193}
     194.kb-amz-product-sync
     195{
     196    width: 120px;
     197    margin-left: 10px;
     198    margin-bottom: 10px;
     199    text-align: center;
     200    display: inline-block;
     201    vertical-align: top;
     202}
     203.kb-amz-product-sync img
     204{
     205    max-width: 100%;
     206}
  • 2kb-amazon-affiliates-store/trunk/template/admin/index.phtml

    r1122895 r1128309  
    77    </div>
    88<?php endif; ?>
     9
     10<?php if (!getKbAmz()->getOption('AttributesCountMessageSeen') && count(getKbAmz()->getOption('productAttributes')) < 5) : ?>
     11    <div class="alert alert-warning" role="alert">
     12        <button aria-label="Close" data-dismiss="alert" class="close" type="button" data-option="AttributesCountMessageSeen" data-option-value="1"><span aria-hidden="true">×</span></button>
     13        Your products show only
     14        <?php
     15        $count = count(getKbAmz()->getOption('productAttributes'));
     16        echo sprintf(
     17            '%s %s.',
     18            $count,
     19            $count == 1 ? 'Attribute' : 'Attributes'
     20        );
     21        ?>
     22        Consider adding more attributes for better selling performance.
     23        <b><a href="?<?php echo http_build_query(array_merge($_GET, array('kbAction' => 'productsAttributes')))?>">Add more attributes</a></b>
     24    </div>
     25<?php endif; ?>
     26
     27
     28
    929<div class="row homepage">
    1030    <div class="col-sm-3">
     
    1535            <div class="col-sm-12" style="font-size: 16px;">
    1636                <div>
    17                     <span class="label label-info">
    18                         <span class="glyphicon glyphicon-usd"></span> Products:
     37                    <span class="label label-primary" title="Products" data-toggle="tooltip" data-placement="top">
     38                        <span class="glyphicon glyphicon-usd"></span>
    1939                        <?php echo getKbAmz()->getProductsCount(); ?>
    2040                    </span>
    21                     &nbsp;&nbsp;
    22                     <span class="label label-info">
    23                         <span class="glyphicon glyphicon-download-alt"></span> To Download:
     41                    &nbsp;
     42                    <span class="label label-primary" title="Products to download" data-toggle="tooltip" data-placement="top">
     43                        <span class="glyphicon glyphicon-download-alt"></span>
    2444                        <?php echo getKbAmz()->getProductsToDownloadCount(); ?>
    2545                    </span>
    26                     &nbsp;&nbsp;
    27                     <span class="label label-info">
    28                         <span class="glyphicon glyphicon-refresh"></span> To Update:
     46                    &nbsp;
     47                    <span class="label label-primary" title="Products to update" data-toggle="tooltip" data-placement="top">
     48                        <span class="glyphicon glyphicon-refresh"></span>
    2949                        <?php echo getKbAmz()->getProductsToUpdateCount(); ?>
    3050                    </span>
    31                     &nbsp;&nbsp;
    32                     <span class="label label-info">
     51                    &nbsp;
     52                    <span class="label label-primary" title="Time to update" data-toggle="tooltip" data-placement="top">
    3353                        <?php
    3454                        $hours = 0;
     
    4868
    4969                        ?>
    50                         <span class="glyphicon glyphicon-time"></span> Time To Update:
     70                        <span class="glyphicon glyphicon-time"></span>
    5171                        <?php echo $hours; ?>h
    5272                    </span>
    53                     &nbsp;&nbsp;
    54                     <span class="label label-info">
    55                         <span class="glyphicon glyphicon-repeat"></span> Requests/Avg. Time:
     73                    &nbsp;
     74                    <span class="label label-primary" title="Requests/Avg. Time" data-toggle="tooltip" data-placement="top">
     75                        <span class="glyphicon glyphicon-signal"></span>
    5676                        <?php echo getKbAmz()->getOption('AmazonRequests', 1); ?>
    5777                        /
    5878                        <?php echo getKbAmz()->getOption('averageTimeToFetch', 1) * 1000; ?>ms
    5979                    </span>
    60                 </div>
    61                 <div>
    62                     <span class="label label-info">
    63                         <span class="glyphicon glyphicon-time"></span> Cron Last Run:
     80                    &nbsp;
     81                    <span class="label label-primary" title="Cron last run" data-toggle="tooltip" data-placement="top">
     82                        <span class="glyphicon glyphicon-time"></span>
    6483                        <?php echo getKbAmz()->getOption('LastCronRun', '-'); ?>
    6584                    </span>
     85                    &nbsp;
     86                    <div title="Amazon Sync Health" data-toggle="tooltip" data-placement="top" style="width: 100px;display: inline-block;margin-bottom: 0px;vertical-align: middle;">
     87                        <?php echo getKbAmzStoreHealthHtml();?>
     88                    </div>
    6689                </div>
    6790                <br/>
     
    222245        $tips[] = 'Every variant is inserted as new post (the same as none variable products). Product with 3 Sizes and 8 Colors will result in inserting 25 posts.(1st the main product and 3x8 Variants)';
    223246        $tips[] = 'From where to get ASIN. <a href="?'.http_build_query(array_merge($_GET, array('kbAction' => 'info'))).'#get-asin">Click here to find</a>.';
     247        ?>
    224248       
     249        <?php if (count(getKbAmz()->getOption('productAttributes')) < 5) : ?>
     250            <?php ob_start();?>
     251            Your products show only
     252            <?php
     253            $count = count(getKbAmz()->getOption('productAttributes'));
     254            echo sprintf(
     255                '%s %s.',
     256                $count,
     257                $count == 1 ? 'Attribute' : 'Attributes'
     258            );
     259            ?>
     260            Consider adding more attributes for better selling performance.
     261            <b><a href="?<?php echo http_build_query(array_merge($_GET, array('kbAction' => 'productsAttributes')))?>">Add more attributes</a></b>
     262            <?php
     263            $tips[] = ob_get_clean();
     264            ?>
     265        <?php endif; ?>
     266
     267       
     268        <?php
    225269        if (!empty($tips)) {
    226270            $tip = $tips[rand(0, count($tips) - 1)];
     
    228272        }
    229273        ?>
    230 <!--        <div class="row icons-actions">
    231             <div class="col-md-3">
    232                 <a href="?<?php echo http_build_query(array_merge($_GET, array('kbAction' => 'createStorePage')));?>" class="btn btn-default">
    233                     <span aria-hidden="true" class="glyphicon glyphicon-home" style="font-size: 50px;display: block;"></span>
    234                     Create Store Page
    235                 </a>
    236             </div>
    237         </div>-->
     274        <div class="icons-actions">
     275<!--            <a href="?<?php echo http_build_query(array_merge($_GET, array('kbAction' => 'createStorePage')));?>" class="btn btn-default">
     276                <span aria-hidden="true" class="glyphicon glyphicon-home" style="font-size: 50px;display: block;"></span>
     277                Create Store Page
     278            </a>
     279            &nbsp;-->
     280            <?php
     281            $siteNetwork = getKbAmz()->getOption('siteNetwork');
     282            $joined      = isset($siteNetwork['siteActive']) && $siteNetwork['siteActive'];
     283            ?>
     284            <a href="?<?php echo http_build_query(array_merge($_GET, array('kbAction' => 'network')));?>" class="btn btn-default" title="<?php echo !$joined ? 'Join to 2kb Amazon Network' : 'Joined to 2kb Amazon Network';?>" data-toggle="tooltip" data-placement="bottom">
     285                <span aria-hidden="true" class="glyphicon glyphicon-globe" style="font-size: 50px;display: block;"></span>
     286                2kb Amazon Network<br/>(beta, tests only)
     287                <?php
     288                echo sprintf(
     289                    '<span class="kb-amz-icon-action-dot %s">&nbsp;</span>',
     290                    $joined ? 'active' : 'not-active'
     291                );
     292                ?>
     293            </a>
     294        </div>
    238295    </div>
    239296</div>
  • 2kb-amazon-affiliates-store/trunk/template/admin/layout.phtml

    r1122895 r1128309  
    11<div id="kb-amz-admin" class="<?php echo $this->bodyClass; ?>">
    2     <br/>
    32    <?php
    43    $params = array();
     
    65    ?>
    76    <div id="kb-amz-header">
    8         <ul class="nav nav-tabs">
    9         <?php
    10             $query = array(
    11                 'page' => $_GET['page'],
    12                 'kbAction' => $_GET['kbAction']
    13             );
    14             $i = 0;
    15             foreach($this->actions as $action):
    16                 if (isset($action['pages'])) {
    17                     $isActive = false;
    18                     $subMenuStr = '';
    19                     foreach ($action['pages'] as $page) {
    20                         $subPageAction = false;
    21                         if (isset($_GET['kbAction']) && $_GET['kbAction'] == $page['action']) {
    22                             $isActive = $subPageAction = true;
    23                         }
    24                         $subMenuStr .= sprintf(
    25                             '<li class="%s"><a href="?%s">%s</a></li>',
    26                             $subPageAction ? 'active' : '',
    27                             http_build_query(array_merge($query, array('kbAction' => $page['action']))),
    28                             $page['label']
     7        <nav class="navbar navbar-default">
     8            <ul class="nav navbar-nav">
     9            <?php
     10                $query = array(
     11                    'page' => $_GET['page'],
     12                    'kbAction' => $_GET['kbAction']
     13                );
     14                $i = 0;
     15                foreach($this->actions as $action):
     16                    if (isset($action['pages'])) {
     17                        $isActive = false;
     18                        $subMenuStr = '';
     19                        foreach ($action['pages'] as $page) {
     20                            $subPageAction = false;
     21                            if (isset($_GET['kbAction']) && $_GET['kbAction'] == $page['action']) {
     22                                $isActive = $subPageAction = true;
     23                            }
     24                            $subMenuStr .= sprintf(
     25                                '<li class="%s"><a href="?%s">%s</a></li>',
     26                                $subPageAction ? 'active' : '',
     27                                http_build_query(array_merge($query, array('kbAction' => $page['action']))),
     28                                $page['label']
     29                            );
     30                        }
     31
     32                        echo sprintf(
     33                            '<li class="dropdown %s"><a class="dropdown-toggle" data-toggle="dropdown" href="#">%s %s</a><ul class="dropdown-menu">%s</ul></li>',
     34                            $isActive ? 'active' : '',
     35                            (isset($action['icon']) ? '<span class="glyphicon '.$action['icon'].'"></span>' : ''),
     36                            $action['label'],
     37                            $subMenuStr
     38                        );
     39                    } else {
     40                        $isActive = false;
     41                        if (isset($_GET['kbAction']) && $_GET['kbAction'] == $action['action']) {
     42                            $isActive= true;
     43                        } else if (!isset($_GET['kbAction']) && ++$i == 1) {
     44                            $isActive= true;
     45                        }
     46                        echo sprintf(
     47                            '<li class="%s"><a href="?%s">%s %s</a></li>',
     48                            $isActive ? 'active' : '',
     49                            http_build_query(array_merge($query, array('kbAction' => $action['action']))),
     50                            (isset($action['icon']) ? '<span class="glyphicon '.$action['icon'].'"></span>' : ''),
     51                            $action['label']
    2952                        );
    3053                    }
    31 
    32                     echo sprintf(
    33                         '<li class="dropdown %s"><a class="dropdown-toggle" data-toggle="dropdown" href="#">%s %s</a><ul class="dropdown-menu">%s</ul></li>',
    34                         $isActive ? 'active' : '',
    35                         (isset($action['icon']) ? '<span class="glyphicon '.$action['icon'].'"></span>' : ''),
    36                         $action['label'],
    37                         $subMenuStr
    38                     );
    39                 } else {
    40                     $isActive = false;
    41                     if (isset($_GET['kbAction']) && $_GET['kbAction'] == $action['action']) {
    42                         $isActive= true;
    43                     } else if (!isset($_GET['kbAction']) && ++$i == 1) {
    44                         $isActive= true;
    45                     }
    46                     echo sprintf(
    47                         '<li class="%s"><a href="?%s">%s %s</a></li>',
    48                         $isActive ? 'active' : '',
    49                         http_build_query(array_merge($query, array('kbAction' => $action['action']))),
    50                         (isset($action['icon']) ? '<span class="glyphicon '.$action['icon'].'"></span>' : ''),
    51                         $action['label']
    52                     );
    53                 }
    54             endforeach;
    55         ?>
    56         </ul>
    57 
     54                endforeach;
     55            ?>
     56            </ul>
     57        </nav>
    5858    </div>
    5959
    6060    <div id="kb-amz-content">
    61         <br/>
    6261        <?php
    6362        if (!empty($this->messages)) {
     
    115114                });
    116115            });
     116            $('[data-toggle="tooltip"]').tooltip()
    117117        });
    118118    })(jQuery, '<?php echo getKbAmzAjaxUrl(); ?>');
  • 2kb-amazon-affiliates-store/trunk/template/admin/productsShortCodes.phtml

    r1004924 r1128309  
    1919                            $params = array();
    2020                            foreach ($code['params'] as $nameParamName => $avaialbe) {
    21                                 $params[] = $nameParamName . '="'.$avaialbe.'"';
     21                                if ($nameParamName) {
     22                                    $params[] = $nameParamName . '="'.$avaialbe.'"';
     23                                } else {
     24                                    $params[] = $avaialbe;
     25                                }
     26                               
    2227                            }
    2328                            echo implode(' ', $params);
     
    2530                    </td>
    2631                    <td>
     32                        <?php if ($code['active'] !== null) : ?>
    2733                        <input type="checkbox" value="1" name="<?php echo $name; ?>[active]" <?php echo $code['active'] ? 'checked="checked"' : '';?>/>
     34                        <?php endif; ?>
    2835                    </td>
    2936                </tr>
  • 2kb-amazon-affiliates-store/trunk/template/default/css/style.css

    r1119725 r1128309  
    482482    width: 100%;
    483483    z-index: 1000;
     484}
     485.kb-amz-product-shortcode{
     486    border: none!important;
     487}
     488.kb-amz-product-shortcode td{
     489    vertical-align: top;
     490}
     491.kb-amz-product-header-shortcode{
     492    font-size: 10pt;
     493    line-height: 1.25;
     494    margin: 0 0 5px;
     495}
     496.kb-amz-product-header-shortcode a{
     497    line-height: inherit;
     498}
     499.kb-amz-product-image-shortcode{
     500    max-width: 160px;
     501    padding-right: 20px!important;
     502}
     503.kb-amz-product-image-shortcode img
     504{
     505    border: none;
     506    margin: 0;
     507    padding: 0;
     508    outline: none;
     509}
     510.kb-amz-product-shortcode .kb-product-attributes
     511{
     512    line-height: 1.2;
     513}
     514.kb-amz-product-shortcode .kb-product-attribute-label
     515{
     516    font-size: 0.8em;
    484517}
    485518/*TB*/
Note: See TracChangeset for help on using the changeset viewer.