Plugin Directory

Changeset 1719190


Ignore:
Timestamp:
08/25/2017 06:25:55 AM (8 years ago)
Author:
ibcl
Message:

version 1.0.4
products wholesale/recommended prices

Location:
cimpress-open/trunk
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • cimpress-open/trunk/assets/css/wizard.css

    r1711591 r1719190  
    815815}
    816816
     817.clb_variant_markup {
     818    font-weight : bolder;
     819}
     820
     821.clb_variant_markup.text-success {
     822    color : #B5D862;
     823}
     824.clb_variant_markup.text-error{
     825    color : #FF0000;
     826}
     827
    817828@media (min-width : 992px) {
    818829    .modal__steps .step {
  • cimpress-open/trunk/assets/js/admin_cimpress_product.js

    r1711591 r1719190  
    357357        var numRows = selectedVariants.length;
    358358        var numImages = 0;
     359
     360
     361        var minPricePercent = 30;
     362        var maxPricePercent = 30;
     363        var maxPrice = 0;
    359364        $.each( selectedVariants, function( index, element ) {
    360365            var rowHtml = rowTemplate;
     
    368373
    369374            var cfgData = productData.configurations[sku];
     375
     376
     377            var cfgPrice = cfgData.price * (100 + minPricePercent ) / 100;
     378            if ( maxPrice < cfgPrice ) {
     379                maxPrice = cfgPrice;
     380            }
    370381            rowHtml = rowHtml.replace( /{{clb_variant_sku}}/g, sku )
    371382                    .replace( /{{clb_variant_image_src}}/g, updateQueryStringParameter( surfaceImages[sku][0], 'width', 100 ) )
    372                     .replace( /{{clb_variant_wholesale_price}}/g, cfgData.price )
    373                     .replace( /{{clb_variant_shop_price}}/g, cfgData.price )
     383                    .replace( /{{clb_variant_ws_price}}/g, cfgData.price.toFixed( 2 ) )
     384                    .replace( /{{clb_variant_markup}}/g, minPricePercent + '%' )
     385                    .replace( /{{clb_variant_shop_price}}/g, cfgPrice.toFixed( 2 ) )
    374386                    .replace( /{{clb_variant_qty_intervals}}/g, JSON.stringify( cfgData.quantity ) )
    375387                    .replace( /{{clb_disabled_class}}/g, numRows > 1 ? '' : 'disabled' );
     
    390402            rowsHtml += rowHtml;
    391403        } );
     404
     405        template = template.replace( /{{wholesale_price_min}}/g, productData.startingPrice.toFixed( 2 ) );
     406        template = template.replace( /{{wholesale_price_max}}/g, productData.maxPrice.toFixed( 2 ) );
     407        template = template.replace( /{{set_all_price}}/g, maxPrice.toFixed( 2 ) );
     408        template = template.replace( /{{wholesale_price_percent_min}}/g, minPricePercent + '%' );
     409        template = template.replace( /{{wholesale_price_percent_max}}/g, maxPricePercent + '%' );
    392410
    393411        template = template.replace( /{{clb_mockup_images}}/g, mockupImages );
     
    479497    } );
    480498    var frame            = null,
    481         clickedUploadBtn = null,
    482         cachedImageIds   = [];//todo: cache image ids
     499        clickedUploadBtn = null;
    483500
    484501    function onChooseImage ( attachment, code, surfaceCode, callback ) {
     
    547564            }
    548565        } );
     566    }
     567
     568    function setVariantPriceMarkup ( parent, price, updateVal ) {
     569        var basePrice = parseFloat( $( '.clb_variant_ws_price', parent ).text() );
     570        if( updateVal ){
     571            $( '.clb_product_variant_shop_price', parent ).val( price.toFixed( 2 ) );
     572        }
     573        var markup = -(100 - (price * 100) / basePrice);
     574
     575        $( '.clb_variant_markup', parent )
     576                .toggleClass( 'text-success', markup >= 30 )
     577                .toggleClass( 'text-error', markup < 0 )
     578                .text( markup.toFixed( 0 ) + "%" );
     579
     580        var percents = $( '.clb_variant_markup' ).text()
     581                .split( '%' )
     582                .filter( function( x ) {return x.length > 0} )
     583                .map(function(x) { return parseFloat(x); })
     584                .sort(function(a,b) {return a-b});
     585
     586        var minMarkup = parseFloat( percents[0] );
     587        var maxMarkup = parseFloat( percents[percents.length - 1] );
     588
     589        $( '#wholesale_price_percent_min', '#step-4-content' ).text( minMarkup.toFixed( 0 ) + "%" );
     590        $( '#wholesale_price_percent_max', '#step-4-content' ).text( maxMarkup.toFixed( 0 ) + "%" );
     591        return markup;
    549592    }
    550593
     
    621664                            }
    622665                            else {
    623                                 $(variations).each( function( index, obj ) {
     666                                $( variations ).each( function( index, obj ) {
    624667                                    $( '#clb_config_container-' + obj.code + '-' + obj.surface ).find( '.clb_loading_mask' ).removeClass( 'active' );
    625668                                } );
     
    677720                $( '.clb_mockup_images_wrapper img:nth-of-type(' + (currentIndex + 1) + ')' ).addClass( 'active' );
    678721                $( '.clb_mockup_navigator .clb_mockup_label' ).html( (currentIndex + 1) + ' / ' + totalImages );
     722            } )
     723            .on( 'keyup change', '#setAllPrice', function( event ) {
     724                event.preventDefault();
     725                var rows = $( '.clb_product_variant_row', '#step-4-content' );
     726                var price = parseFloat( $( this ).val() );
     727
     728                rows.each( function() {
     729                    setVariantPriceMarkup( this, price, true );
     730                } );
     731
     732            } )
     733            .on( 'change keyup', '.clb_product_variant_shop_price', function( event ) {
     734                event.preventDefault();
     735
     736                var price = parseFloat( $( this ).val() );
     737
     738                setVariantPriceMarkup( $( this ).closest( 'tr' ), price );
     739
     740            } )
     741            .on( 'blur', '.clb_product_variant_shop_price', function( event ) {
     742                event.preventDefault();
     743
     744                var price = parseFloat( $( this ).val() );
     745                $(this).val(price.toFixed(2));
     746
    679747            } );
    680748
  • cimpress-open/trunk/cloudlab-cimpress.php

    r1711591 r1719190  
    77    * Description: Plugin for integration of Cimpress Open API into WooCommerce
    88    * Author: CloudLab AG
    9     * Version: 1.0.3
     9    * Version: 1.0.4
    1010    * Author URI: https://open.cimpress.com/
    1111    * Requires at least: 4.7
     
    1818
    1919
    20     define( 'CLOUDLAB_CIMPRESS_VERSION', '1.0.2' );
     20    define( 'CLOUDLAB_CIMPRESS_VERSION', '1.0.4' );
    2121    define( 'CLOUDLAB_CIMPRESS_ROOT', dirname( __FILE__ ) . DIRECTORY_SEPARATOR );
    2222    define( 'CLOUDLAB_CIMPRESS_URL', plugin_dir_url( __FILE__ ) );
  • cimpress-open/trunk/includes/admin/cloudlab-cimpress-admin.php

    r1711591 r1719190  
    906906
    907907                $index = 1;
     908               
     909                $productDefaultAttributeValues = array();
     910                $defaultValuesFlag = true;
     911               
    908912                foreach ( $variation_codes as $variation_code ) {
    909913                    $variation_title = sprintf( esc_html__( 'Variation #%s of %s', CLOUDLAB_CIMPRESS_DOMAIN ), $index, get_the_title( $product_id ) );
     
    962966                    if ( isset( $configurationData['attributes'] ) ) {
    963967                        foreach ( $configurationData['attributes'] as $attributeCode => $attributeValue ) {
    964                             $attribute_key = 'attribute_' . sanitize_title( $attributes[ $attributeCode ]['name'] );
     968                            $att_code = sanitize_title( $attributes[ $attributeCode ]['name'] );
     969                            $attribute_key = 'attribute_' . $att_code;
     970                            if( $defaultValuesFlag ) {
     971                                $productDefaultAttributeValues[$att_code] = $attributeValue;
     972                            }
    965973                            update_post_meta( $variation_id, $attribute_key, $attributeValue );
    966974                        }
    967975                    }
     976                    $defaultValuesFlag = false;
    968977                    update_post_meta( $variation_id, 'is_cloudlab_cimpress_product', 1 );
    969978                    update_post_meta( $variation_id, 'cloudlab_cimpress_sku', $variation_code );
     
    10001009                    gc_collect_cycles();
    10011010                }
     1011
     1012                update_post_meta( $product_id, '_default_attributes', $productDefaultAttributeValues);
    10021013
    10031014                $message = __( 'Product was successfully added!', CLOUDLAB_CIMPRESS_DOMAIN ) . ' ';
  • cimpress-open/trunk/includes/admin/templates/wizard.php

    r1711591 r1719190  
    292292                        <col>
    293293                        <col>
     294                        <col>
    294295                        <col width="1">
    295296                    </colgroup>
    296297                    <thead>
     298
    297299                        <tr>
    298                             <th><?php esc_html_e( 'Preview', CLOUDLAB_CIMPRESS_DOMAIN ) ?></th>
     300                            <th style="width: 100px;"><?php esc_html_e( 'Preview', CLOUDLAB_CIMPRESS_DOMAIN ) ?></th>
    299301                            <th><?php esc_html_e( 'Options', CLOUDLAB_CIMPRESS_DOMAIN ) ?></th>
     302                            <th style="width: 150px;"><?php esc_html_e( 'Wholesale Price', CLOUDLAB_CIMPRESS_DOMAIN ) ?></th>
     303                            <th style="width: 150px;"><?php esc_html_e( 'Markup', CLOUDLAB_CIMPRESS_DOMAIN ) ?></th>
    300304                            <th><?php esc_html_e( 'Shop Price', CLOUDLAB_CIMPRESS_DOMAIN ) ?></th>
     305                            <th style="width: 30px">&nbsp;</th>
     306                        </tr>
     307                        <tr>
     308                            <th colspan="2">&nbsp;</th>
     309                            <th><span id="wholesale_price_min">{{wholesale_price_min}}</span> — <span id="wholesale_price_max">{{wholesale_price_max}}</span></th>
     310                            <th><span id="wholesale_price_percent_min">{{wholesale_price_percent_min}}</span> — <span id="wholesale_price_percent_max">{{wholesale_price_percent_max}}</span></th>
     311                            <th><input type="text" id="setAllPrice" name="setAllPrice" value="{{set_all_price}}"/></th>
    301312                            <th>&nbsp;</th>
    302313                        </tr>
     
    316327            {{clb_variant_options}}
    317328        </td>
    318         <td>
    319             <input type="text" value="0.0" required class="clb_product_variant_shop_price"
     329        <td class="clb_variant_ws_price">
     330            {{clb_variant_ws_price}}
     331        </td>
     332        <td>
     333            <span class="clb_variant_markup text-success" id="">{{clb_variant_markup}}</span>
     334        </td>
     335        <td>
     336            <input type="text" value="{{clb_variant_shop_price}}" required class="clb_product_variant_shop_price"
    320337                   name="clb_product_configuration[{{clb_variant_sku}}][shop_price]"/>
    321338            <input type="hidden" value="{{clb_variant_qty_intervals}}"
  • cimpress-open/trunk/includes/config.php

    r1711591 r1719190  
    2323    define( 'CLOUDLAB_CIMPRESS_CSS_URL', CLOUDLAB_CIMPRESS_ASSETS_URL . 'css/' );
    2424    define( 'CLOUDLAB_CIMPRESS_REST_BASE_URI', 'https://api.your-printq.com/cimpress/' );
    25     define( 'CLOUDLAB_CIMPRESS_REST_PRODUCTS_VERSION', 3 );
     25    define( 'CLOUDLAB_CIMPRESS_REST_PRODUCTS_VERSION', 4 );
    2626    define( 'CLOUDLAB_CIMPRESS_REST_PRODUCTS_URI', CLOUDLAB_CIMPRESS_REST_BASE_URI . 'products/v' . CLOUDLAB_CIMPRESS_REST_PRODUCTS_VERSION  );
    2727    define( 'CLOUDLAB_CIMPRESS_REST_ORDERS_URI', CLOUDLAB_CIMPRESS_REST_BASE_URI . 'processOrder/' );
  • cimpress-open/trunk/readme.txt

    r1711591 r1719190  
    2424
    2525A free Cimpress Account is required to use this extension. [Click here to sign up](https://open.cimpress.com/ "Join Us").
     26
     27For any questions or help please contact us at: [email protected]
    2628
    2729<h4>Know limitations</h4>
     
    6062<h4>How it works?</h4>
    6163
    62 After creating an account on the Cimpress Open platform, add the API key into the extension.
     64After creating an account on the Cimpress Open platform, add your credentials into the extension.
    6365When an order is created in your WooCommerce shop using a Cimpress product, that order
    6466will be sent to the Cimpress Open Platform, where we print and ship it to your customer.
     
    129131== Changelog ==
    130132
     133= 1.0.4 =
     134* added variant wholesale price
     135* variant suggested price
     136* default product image
     137
    131138= 1.0.3 =
    132139* Added "Apply image to all variants" button
     
    143150
    144151== Upgrade Notice ==
     152
     153= 1.0.4 =
     154* Now it's easier to configure your variants prices using only one input box
     155
    145156= 1.0.3 =
    146157* Admin is now able to apply a single image to all selected variants in wizard
Note: See TracChangeset for help on using the changeset viewer.