Changeset 1268048
- Timestamp:
- 10/18/2015 01:42:33 AM (10 years ago)
- Location:
- bulk-photo-to-product-importer-extension-for-woocommerce/trunk
- Files:
-
- 1 added
- 2 deleted
- 8 edited
-
assets/images/plugin-directory-assets (deleted)
-
assets/js/admin.js (modified) (4 diffs)
-
bptpi.php (modified) (3 diffs)
-
classes/ajax.php (modified) (8 diffs)
-
classes/product.php (modified) (2 diffs)
-
classes/variation-group.php (modified) (5 diffs)
-
deployment-scripts (deleted)
-
front-end/assets/js/frontend.js (modified) (1 diff)
-
includes/html.php (modified) (2 diffs)
-
readme.md (added)
-
settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
bulk-photo-to-product-importer-extension-for-woocommerce/trunk/assets/js/admin.js
r1249434 r1268048 38 38 39 39 $( document ).on('click', '#migrate-variations', this.GeneralSettings.migrate); 40 $( document ).on('click', '#ptp-variation-fix', this.GeneralSettings.fixVariations); 40 41 41 42 // Add 1 or more variation fields on load … … 432 433 '</td>' + 433 434 '<td>' + 435 '<input type="checkbox" name="variations['+ variationCount +'][downloadable]" checked="checked" style="height: 16px; width: 16px;"/>' + 436 '</td>' + 437 '<td>' + 434 438 '<span type="text" class="remove-variation-row control dashicons dashicons-no"></span>' + 435 439 '<span type="text" class="add-variation-row control dashicons dashicons-plus-alt"></span>' + … … 517 521 $('#update-variation-group').css('width', $('#update-variation-group').css('width').replace(/[^-\d\.]/g, '')).val( 'Saving...' ).prop( 'disabled', 'disabled' ).addClass('loading-primary'); 518 522 $.post(PTPImporter_Vars.ajaxurl, data, function(res) { 519 try{ 523 524 // Request separator for escaping server corruptions 525 var responseBracketStart = '_JSON_START_'; 526 var responseBracketEnd = '_JSON_END_'; 527 528 if (res.indexOf('_JSON_START_') == -1) { 529 return; 530 } 531 532 res = res.substring( res.indexOf( responseBracketStart ) + responseBracketStart.length, res.indexOf( responseBracketEnd ) ); 533 534 try{ 520 535 res = $.parseJSON(res); 521 536 … … 1102 1117 1103 1118 return false; 1119 }, 1120 fixVariations: function(e) { 1121 e.preventDefault(); 1122 1123 var that = $(this); 1124 var data = { 1125 action: 'ptp_fix_variations' 1126 } 1127 1128 $.post(PTPImporter_Vars.ajaxurl, data, function(res) { 1129 console.log( res ); 1130 }); 1131 1132 console.log(PTPImporter_Vars.ajaxurl); 1104 1133 } 1105 1134 } -
bulk-photo-to-product-importer-extension-for-woocommerce/trunk/bptpi.php
r1249460 r1268048 6 6 Author: The Portland Company, Designed by Spencer Hill, Coded by Redeye Adaya 7 7 Author URI: http://www.theportlandcompany.com 8 Version: 2.4. 48 Version: 2.4.6 9 9 Copyright: 2015 The Portland Company 10 10 License: GPL v3 … … 24 24 * @var string 25 25 */ 26 public $version = '2.4. 4';26 public $version = '2.4.6'; 27 27 28 28 /** … … 125 125 */ 126 126 private static $uploader_sys = ''; 127 128 /** 129 * @var string 130 */ 131 public $variation_is_downloadable_meta_key = '_downloadable'; 127 132 128 133 function __construct() { -
bulk-photo-to-product-importer-extension-for-woocommerce/trunk/classes/ajax.php
r1249460 r1268048 39 39 add_action('wp_ajax_nopriv_ptp_remove_cart_item', array($this, 'remove_cart_item')); 40 40 add_action('wp_ajax_ptp_remove_cart_item', array($this, 'remove_cart_item')); 41 42 // Settings > Variations fix 43 add_action('wp_ajax_nopriv_ptp_fix_variations', array($this, 'fix_variations')); 44 add_action('wp_ajax_ptp_fix_variations', array($this, 'fix_variations')); 41 45 42 46 add_action('wp_ajax_ptp_activate', array($this, 'activate')); … … 252 256 253 257 $variations = get_option('_transient_wc_product_children_ids_' . $grouped_product_id . $version_value); 258 259 254 260 if (sizeof($variations) == 0) { 255 261 continue; … … 370 376 371 377 if (!$posted['variations']) { 378 echo '_JSON_START_'; 372 379 echo json_encode(array( 373 380 'success' => false, 374 381 'error' => 'You must add at least one variation.' 375 382 )); 383 echo '_JSON_END_'; 376 384 377 385 exit; … … 384 392 385 393 if (!$result) { 394 echo '_JSON_START_'; 386 395 echo json_encode(array( 387 396 'success' => false, … … 390 399 'error' => $result 391 400 )); 401 echo '_JSON_END_'; 392 402 393 403 exit; … … 399 409 for ($i = 0; $i < count($parents); $i++) $dashes .= '—'; 400 410 411 echo '_JSON_START_'; 401 412 echo json_encode(array( 402 413 'success' => true, … … 406 417 'parent' => intval($posted['parent-group']), 407 418 )); 419 echo '_JSON_END_'; 408 420 409 421 exit; … … 601 613 602 614 /** 615 * Fix broken variations on the options table 616 */ 617 public function fix_variations() { 618 global $wpdb; 619 620 $variation_query = "SELECT * FROM {$wpdb->prefix}options WHERE `option_name` LIKE '_transient_wc_product_children_ids_%'"; 621 $variation_groups = $wpdb->get_results($variation_query, ARRAY_A); 622 623 echo '<pre>' . print_r($variation_groups) . '</pre>'; 624 } 625 626 /** 603 627 * Activate this plugin 604 628 * -
bulk-photo-to-product-importer-extension-for-woocommerce/trunk/classes/product.php
r1249460 r1268048 141 141 142 142 // Set as downloadable 143 $metadata['_downloadable'] = 'yes';143 $metadata['_downloadable'] = isset($variation['downloadable']) ? 'yes' : 'no'; 144 144 // Set as virtual' 145 145 $metadata['_virtual'] = 'yes'; … … 230 230 231 231 // Set as downloadable 232 $metadata['_downloadable'] = 'yes';232 $metadata['_downloadable'] = isset($variation['downloadable']) ? 'yes' : 'no'; 233 233 // Set download path 234 234 $metadata['_downloadable_files'] = array( $file_path ); -
bulk-photo-to-product-importer-extension-for-woocommerce/trunk/classes/variation-group.php
r1178647 r1268048 164 164 $variations[$count]['name'] = get_post_field( 'post_title', $_variation->object_id ); 165 165 $variations[$count]['price'] = get_post_meta( $_variation->object_id, $ptp_importer->variation_price_meta_key, true ); 166 $variations[$count][ 'is-downloadable'] = get_post_meta( $_variation->object_id, $ptp_importer->variation_is_downloadable_meta_key, true );166 $variations[$count][$ptp_importer->variation_is_downloadable_meta_key] = get_post_meta( $_variation->object_id, $ptp_importer->variation_is_downloadable_meta_key, true ); 167 167 $variations[$count]['downloadable-width'] = get_post_meta( $_variation->object_id, $ptp_importer->variation_downloadable_width_meta_key, true ); 168 168 $variations[$count]['downloadable-height'] = get_post_meta( $_variation->object_id, $ptp_importer->variation_downloadable_height_meta_key, true ); … … 214 214 215 215 add_post_meta( $post_id, $ptp_importer->variation_price_meta_key, $variation['price'] ); 216 add_post_meta( $post_id, $ptp_importer->variation_is_downloadable_meta_key, $variation['downloadable']);216 add_post_meta( $post_id, $ptp_importer->variation_is_downloadable_meta_key, isset($variation['downloadable']) ? 'yes' : 'no' ); 217 217 add_post_meta( $post_id, $ptp_importer->variation_downloadable_width_meta_key, $variation['downloadable-width'] ); 218 218 add_post_meta( $post_id, $ptp_importer->variation_downloadable_height_meta_key, $variation['downloadable-height'] ); … … 274 274 275 275 add_post_meta( $post_id, $ptp_importer->variation_price_meta_key, $variation['price'] ); 276 add_post_meta( $post_id, $ptp_importer->variation_is_downloadable_meta_key, $variation['downloadable']);276 add_post_meta( $post_id, $ptp_importer->variation_is_downloadable_meta_key, isset($variation['downloadable']) ? 'yes' : 'no' ); 277 277 add_post_meta( $post_id, $ptp_importer->variation_downloadable_width_meta_key, $variation['downloadable-width'] ); 278 278 add_post_meta( $post_id, $ptp_importer->variation_downloadable_height_meta_key, $variation['downloadable-height'] ); … … 312 312 $post_id = wp_update_post( $args ); 313 313 update_post_meta( $variation['id'], $ptp_importer->variation_price_meta_key, $variation['price'] ); 314 update_post_meta( $post_id, $ptp_importer->variation_is_downloadable_meta_key, $variation['downloadable']);314 update_post_meta( $post_id, $ptp_importer->variation_is_downloadable_meta_key, isset($variation['downloadable']) ? 'yes' : 'no' ); 315 315 update_post_meta( $post_id, $ptp_importer->variation_downloadable_width_meta_key, $variation['downloadable-width'] ); 316 316 update_post_meta( $post_id, $ptp_importer->variation_downloadable_height_meta_key, $variation['downloadable-height'] ); … … 408 408 */ 409 409 public function new_variations( $old, $mixed ) { 410 410 411 $old_ids = array(); 411 412 foreach ( $old as $variation ) { -
bulk-photo-to-product-importer-extension-for-woocommerce/trunk/front-end/assets/js/frontend.js
r1249434 r1268048 61 61 62 62 $.each( variations, function( i, j ) { 63 if( !form.find( '#variation_group_opt_' + j.id + '' ).length ) {63 if( j.downloadable == 'yes' && !form.find( '#variation_group_opt_' + j.id + '' ).length ) { 64 64 form.find( '.quick-order-variation' ).append( '<option id="variation_group_opt_' + j.id + '" value="' + j.name + '">' + j.name + '</option>' ); 65 65 } -
bulk-photo-to-product-importer-extension-for-woocommerce/trunk/includes/html.php
r1178647 r1268048 123 123 <input class="price" type="text" name="variations[<?php echo $count; ?>][price]" value="<?php echo $item['price']; ?>" placeholder="Price" /> 124 124 </td> 125 <td> 126 <input type="checkbox" style="height: 16px; width: 16px;" name="variations[<?php echo $count; ?>][downloadable]" <?php echo $item['_downloadable'] == 'yes' ? 'checked="checked"' : '' ?> /> 127 </td> 125 128 </tr> 126 129 </table> … … 262 265 $groups[] = array( 263 266 'name' => $g[ 'name' ], 264 'id' => $g[ 'id' ] 267 'id' => $g[ 'id' ], 268 'downloadable' => $g[ '_downloadable' ] 265 269 ); 266 270 } -
bulk-photo-to-product-importer-extension-for-woocommerce/trunk/settings.php
r1178647 r1268048 91 91 </td> 92 92 </tr> 93 93 94 <!-- <tr>--> 95 <!-- <td class="label">--> 96 <!-- <label>--><?php //_e( 'Broken Variations', 'ptp' ); ?><!--</label>--> 97 <!-- </td>--> 98 <!-- <td>--> 99 <!-- <a href="#" id="ptp-variation-fix">Click here to fix variations</a>--> 100 <!-- </td>--> 101 <!-- </tr>--> 94 102 95 103 <?php if ( $variation_migrate->groups() ) : ?>
Note: See TracChangeset
for help on using the changeset viewer.