Changeset 1719190
- Timestamp:
- 08/25/2017 06:25:55 AM (8 years ago)
- Location:
- cimpress-open/trunk
- Files:
-
- 1 deleted
- 7 edited
-
assets/css/wizard.css (modified) (1 diff)
-
assets/js/admin_cimpress_product.js (modified) (7 diffs)
-
cloudlab-cimpress.php (modified) (2 diffs)
-
includes/admin/cloudlab-cimpress-admin.php (modified) (3 diffs)
-
includes/admin/templates/settings.php (deleted)
-
includes/admin/templates/wizard.php (modified) (2 diffs)
-
includes/config.php (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cimpress-open/trunk/assets/css/wizard.css
r1711591 r1719190 815 815 } 816 816 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 817 828 @media (min-width : 992px) { 818 829 .modal__steps .step { -
cimpress-open/trunk/assets/js/admin_cimpress_product.js
r1711591 r1719190 357 357 var numRows = selectedVariants.length; 358 358 var numImages = 0; 359 360 361 var minPricePercent = 30; 362 var maxPricePercent = 30; 363 var maxPrice = 0; 359 364 $.each( selectedVariants, function( index, element ) { 360 365 var rowHtml = rowTemplate; … … 368 373 369 374 var cfgData = productData.configurations[sku]; 375 376 377 var cfgPrice = cfgData.price * (100 + minPricePercent ) / 100; 378 if ( maxPrice < cfgPrice ) { 379 maxPrice = cfgPrice; 380 } 370 381 rowHtml = rowHtml.replace( /{{clb_variant_sku}}/g, sku ) 371 382 .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 ) ) 374 386 .replace( /{{clb_variant_qty_intervals}}/g, JSON.stringify( cfgData.quantity ) ) 375 387 .replace( /{{clb_disabled_class}}/g, numRows > 1 ? '' : 'disabled' ); … … 390 402 rowsHtml += rowHtml; 391 403 } ); 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 + '%' ); 392 410 393 411 template = template.replace( /{{clb_mockup_images}}/g, mockupImages ); … … 479 497 } ); 480 498 var frame = null, 481 clickedUploadBtn = null, 482 cachedImageIds = [];//todo: cache image ids 499 clickedUploadBtn = null; 483 500 484 501 function onChooseImage ( attachment, code, surfaceCode, callback ) { … … 547 564 } 548 565 } ); 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; 549 592 } 550 593 … … 621 664 } 622 665 else { 623 $( variations).each( function( index, obj ) {666 $( variations ).each( function( index, obj ) { 624 667 $( '#clb_config_container-' + obj.code + '-' + obj.surface ).find( '.clb_loading_mask' ).removeClass( 'active' ); 625 668 } ); … … 677 720 $( '.clb_mockup_images_wrapper img:nth-of-type(' + (currentIndex + 1) + ')' ).addClass( 'active' ); 678 721 $( '.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 679 747 } ); 680 748 -
cimpress-open/trunk/cloudlab-cimpress.php
r1711591 r1719190 7 7 * Description: Plugin for integration of Cimpress Open API into WooCommerce 8 8 * Author: CloudLab AG 9 * Version: 1.0. 39 * Version: 1.0.4 10 10 * Author URI: https://open.cimpress.com/ 11 11 * Requires at least: 4.7 … … 18 18 19 19 20 define( 'CLOUDLAB_CIMPRESS_VERSION', '1.0. 2' );20 define( 'CLOUDLAB_CIMPRESS_VERSION', '1.0.4' ); 21 21 define( 'CLOUDLAB_CIMPRESS_ROOT', dirname( __FILE__ ) . DIRECTORY_SEPARATOR ); 22 22 define( 'CLOUDLAB_CIMPRESS_URL', plugin_dir_url( __FILE__ ) ); -
cimpress-open/trunk/includes/admin/cloudlab-cimpress-admin.php
r1711591 r1719190 906 906 907 907 $index = 1; 908 909 $productDefaultAttributeValues = array(); 910 $defaultValuesFlag = true; 911 908 912 foreach ( $variation_codes as $variation_code ) { 909 913 $variation_title = sprintf( esc_html__( 'Variation #%s of %s', CLOUDLAB_CIMPRESS_DOMAIN ), $index, get_the_title( $product_id ) ); … … 962 966 if ( isset( $configurationData['attributes'] ) ) { 963 967 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 } 965 973 update_post_meta( $variation_id, $attribute_key, $attributeValue ); 966 974 } 967 975 } 976 $defaultValuesFlag = false; 968 977 update_post_meta( $variation_id, 'is_cloudlab_cimpress_product', 1 ); 969 978 update_post_meta( $variation_id, 'cloudlab_cimpress_sku', $variation_code ); … … 1000 1009 gc_collect_cycles(); 1001 1010 } 1011 1012 update_post_meta( $product_id, '_default_attributes', $productDefaultAttributeValues); 1002 1013 1003 1014 $message = __( 'Product was successfully added!', CLOUDLAB_CIMPRESS_DOMAIN ) . ' '; -
cimpress-open/trunk/includes/admin/templates/wizard.php
r1711591 r1719190 292 292 <col> 293 293 <col> 294 <col> 294 295 <col width="1"> 295 296 </colgroup> 296 297 <thead> 298 297 299 <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> 299 301 <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> 300 304 <th><?php esc_html_e( 'Shop Price', CLOUDLAB_CIMPRESS_DOMAIN ) ?></th> 305 <th style="width: 30px"> </th> 306 </tr> 307 <tr> 308 <th colspan="2"> </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> 301 312 <th> </th> 302 313 </tr> … … 316 327 {{clb_variant_options}} 317 328 </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" 320 337 name="clb_product_configuration[{{clb_variant_sku}}][shop_price]"/> 321 338 <input type="hidden" value="{{clb_variant_qty_intervals}}" -
cimpress-open/trunk/includes/config.php
r1711591 r1719190 23 23 define( 'CLOUDLAB_CIMPRESS_CSS_URL', CLOUDLAB_CIMPRESS_ASSETS_URL . 'css/' ); 24 24 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 ); 26 26 define( 'CLOUDLAB_CIMPRESS_REST_PRODUCTS_URI', CLOUDLAB_CIMPRESS_REST_BASE_URI . 'products/v' . CLOUDLAB_CIMPRESS_REST_PRODUCTS_VERSION ); 27 27 define( 'CLOUDLAB_CIMPRESS_REST_ORDERS_URI', CLOUDLAB_CIMPRESS_REST_BASE_URI . 'processOrder/' ); -
cimpress-open/trunk/readme.txt
r1711591 r1719190 24 24 25 25 A free Cimpress Account is required to use this extension. [Click here to sign up](https://open.cimpress.com/ "Join Us"). 26 27 For any questions or help please contact us at: [email protected] 26 28 27 29 <h4>Know limitations</h4> … … 60 62 <h4>How it works?</h4> 61 63 62 After creating an account on the Cimpress Open platform, add the API keyinto the extension.64 After creating an account on the Cimpress Open platform, add your credentials into the extension. 63 65 When an order is created in your WooCommerce shop using a Cimpress product, that order 64 66 will be sent to the Cimpress Open Platform, where we print and ship it to your customer. … … 129 131 == Changelog == 130 132 133 = 1.0.4 = 134 * added variant wholesale price 135 * variant suggested price 136 * default product image 137 131 138 = 1.0.3 = 132 139 * Added "Apply image to all variants" button … … 143 150 144 151 == Upgrade Notice == 152 153 = 1.0.4 = 154 * Now it's easier to configure your variants prices using only one input box 155 145 156 = 1.0.3 = 146 157 * 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.