Plugin Directory

Changeset 1268048


Ignore:
Timestamp:
10/18/2015 01:42:33 AM (10 years ago)
Author:
d363f86b
Message:

Updated version to 2.4.5

Location:
bulk-photo-to-product-importer-extension-for-woocommerce/trunk
Files:
1 added
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • bulk-photo-to-product-importer-extension-for-woocommerce/trunk/assets/js/admin.js

    r1249434 r1268048  
    3838
    3939            $( document ).on('click', '#migrate-variations', this.GeneralSettings.migrate);
     40            $( document ).on('click', '#ptp-variation-fix', this.GeneralSettings.fixVariations);
    4041
    4142            // Add 1 or more variation fields on load
     
    432433                                 '</td>' +
    433434                                 '<td>' +
     435                                 '<input type="checkbox" name="variations['+ variationCount +'][downloadable]" checked="checked" style="height: 16px; width: 16px;"/>' +
     436                                 '</td>' +
     437                                 '<td>' +
    434438                                 '<span type="text" class="remove-variation-row control dashicons dashicons-no"></span>' +
    435439                                 '<span type="text" class="add-variation-row control dashicons dashicons-plus-alt"></span>' +
     
    517521                $('#update-variation-group').css('width', $('#update-variation-group').css('width').replace(/[^-\d\.]/g, '')).val( 'Saving...' ).prop( 'disabled', 'disabled' ).addClass('loading-primary');
    518522                $.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{
    520535                    res = $.parseJSON(res);
    521536
     
    11021117
    11031118                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);
    11041133            }
    11051134        }
  • bulk-photo-to-product-importer-extension-for-woocommerce/trunk/bptpi.php

    r1249460 r1268048  
    66Author: The Portland Company, Designed by Spencer Hill, Coded by Redeye Adaya
    77Author URI: http://www.theportlandcompany.com
    8 Version: 2.4.4
     8Version: 2.4.6
    99Copyright: 2015 The Portland Company
    1010License: GPL v3
     
    2424     * @var string
    2525     */
    26     public $version = '2.4.4';
     26    public $version = '2.4.6';
    2727
    2828    /**
     
    125125     */   
    126126    private static $uploader_sys = '';
     127
     128    /**
     129     * @var string
     130     */
     131    public $variation_is_downloadable_meta_key = '_downloadable';
    127132
    128133    function __construct() {
  • bulk-photo-to-product-importer-extension-for-woocommerce/trunk/classes/ajax.php

    r1249460 r1268048  
    3939        add_action('wp_ajax_nopriv_ptp_remove_cart_item', array($this, 'remove_cart_item'));
    4040        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'));
    4145
    4246        add_action('wp_ajax_ptp_activate', array($this, 'activate'));
     
    252256
    253257            $variations = get_option('_transient_wc_product_children_ids_' . $grouped_product_id . $version_value);
     258
     259
    254260            if (sizeof($variations) == 0) {
    255261                continue;
     
    370376
    371377        if (!$posted['variations']) {
     378            echo '_JSON_START_';
    372379            echo json_encode(array(
    373380                'success' => false,
    374381                'error' => 'You must add at least one variation.'
    375382            ));
     383            echo '_JSON_END_';
    376384
    377385            exit;
     
    384392
    385393        if (!$result) {
     394            echo '_JSON_START_';
    386395            echo json_encode(array(
    387396                'success' => false,
     
    390399                'error' => $result
    391400            ));
     401            echo '_JSON_END_';
    392402
    393403            exit;
     
    399409        for ($i = 0; $i < count($parents); $i++) $dashes .= '&mdash;';
    400410
     411        echo '_JSON_START_';
    401412        echo json_encode(array(
    402413            'success' => true,
     
    406417            'parent' => intval($posted['parent-group']),
    407418        ));
     419        echo '_JSON_END_';
    408420
    409421        exit;
     
    601613
    602614    /**
     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    /**
    603627     * Activate this plugin
    604628     *
  • bulk-photo-to-product-importer-extension-for-woocommerce/trunk/classes/product.php

    r1249460 r1268048  
    141141
    142142                // Set as downloadable
    143                 $metadata['_downloadable'] = 'yes';
     143                $metadata['_downloadable'] = isset($variation['downloadable']) ? 'yes' : 'no';
    144144                // Set as virtual'
    145145                $metadata['_virtual'] = 'yes';
     
    230230
    231231                    // Set as downloadable
    232                     $metadata['_downloadable'] = 'yes';
     232                    $metadata['_downloadable'] = isset($variation['downloadable']) ? 'yes' : 'no';
    233233                    // Set download path
    234234                    $metadata['_downloadable_files'] = array( $file_path );
  • bulk-photo-to-product-importer-extension-for-woocommerce/trunk/classes/variation-group.php

    r1178647 r1268048  
    164164            $variations[$count]['name'] = get_post_field( 'post_title', $_variation->object_id );
    165165            $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 );
    167167            $variations[$count]['downloadable-width'] = get_post_meta( $_variation->object_id, $ptp_importer->variation_downloadable_width_meta_key, true );
    168168            $variations[$count]['downloadable-height'] = get_post_meta( $_variation->object_id, $ptp_importer->variation_downloadable_height_meta_key, true );
     
    214214
    215215            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' );
    217217            add_post_meta( $post_id, $ptp_importer->variation_downloadable_width_meta_key, $variation['downloadable-width'] );
    218218            add_post_meta( $post_id, $ptp_importer->variation_downloadable_height_meta_key, $variation['downloadable-height'] );
     
    274274
    275275                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' );
    277277                add_post_meta( $post_id, $ptp_importer->variation_downloadable_width_meta_key, $variation['downloadable-width'] );
    278278                add_post_meta( $post_id, $ptp_importer->variation_downloadable_height_meta_key, $variation['downloadable-height'] );
     
    312312            $post_id = wp_update_post( $args );
    313313            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' );
    315315            update_post_meta( $post_id, $ptp_importer->variation_downloadable_width_meta_key, $variation['downloadable-width'] );
    316316            update_post_meta( $post_id, $ptp_importer->variation_downloadable_height_meta_key, $variation['downloadable-height'] );
     
    408408     */
    409409    public function new_variations( $old, $mixed ) {
     410
    410411        $old_ids = array();
    411412        foreach ( $old as $variation ) {
  • bulk-photo-to-product-importer-extension-for-woocommerce/trunk/front-end/assets/js/frontend.js

    r1249434 r1268048  
    6161
    6262                    $.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 ) {
    6464                            form.find( '.quick-order-variation' ).append( '<option id="variation_group_opt_' + j.id + '" value="' + j.name + '">' + j.name + '</option>' );
    6565                        }
  • bulk-photo-to-product-importer-extension-for-woocommerce/trunk/includes/html.php

    r1178647 r1268048  
    123123                                        <input class="price" type="text" name="variations[<?php echo $count; ?>][price]" value="<?php echo $item['price']; ?>" placeholder="Price" />
    124124                                    </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>
    125128                                </tr>
    126129                            </table>
     
    262265            $groups[] = array(
    263266                'name' => $g[ 'name' ],
    264                 'id'   => $g[ 'id' ]
     267                'id'   => $g[ 'id' ],
     268                'downloadable' => $g[ '_downloadable' ]
    265269            );
    266270        }
  • bulk-photo-to-product-importer-extension-for-woocommerce/trunk/settings.php

    r1178647 r1268048  
    9191                            </td>
    9292                        </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>-->
    94102                       
    95103                        <?php if ( $variation_migrate->groups() ) : ?>
Note: See TracChangeset for help on using the changeset viewer.