Plugin Directory

Changeset 2173543


Ignore:
Timestamp:
10/15/2019 09:02:44 AM (6 years ago)
Author:
soft8soft
Message:

New version 2.16

Location:
verge3d/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • verge3d/trunk/app.php

    r2121979 r2173543  
    22
    33define('V3D_DEFAULT_CANVAS_WIDTH', 800);
    4 define('V3D_DEFAULT_CANVAS_HEIGHT', 600);
     4define('V3D_DEFAULT_CANVAS_HEIGHT', 500);
    55
    66if (!class_exists('WP_List_Table')){
     
    1515    }
    1616
     17    add_filter('admin_footer_text', 'v3d_replace_footer');
     18
    1719    $action = (!empty($_REQUEST['action'])) ? sanitize_text_field($_REQUEST['action']) : '';
    1820
     
    2224
    2325        <div class="wrap">
    24           <h1 class="wp-heading-inline">Add a new Verge3D application</h1>
     26          <h1 class="wp-heading-inline">New Verge3D application</h1>
    2527          <form method="get" class="validate">
    2628            <input type="hidden" name="page" value="<?php echo sanitize_text_field($_REQUEST['page']) ?>" />
     
    3638              </tbody>
    3739            </table>
    38             <p class="submit"><input type="submit" class="button button-primary"></p>
     40            <p class="submit"><input type="submit" class="button button-primary" value="Next"></p>
    3941          </form>
    4042        </div>
     
    5456            ),
    5557        );
    56         wp_insert_post($post_arr);
    57         v3d_redirect_app_list();
     58        $app_id = wp_insert_post($post_arr);
     59        v3d_redirect_app($app_id);
    5860        break;
    5961    case 'edit':
     
    7476        ?>
    7577        <div class="wrap">
    76           <h1 class="wp-heading-inline">Update Verge3D Application</h1>
     78          <h1 class="wp-heading-inline">Manage Verge3D Application</h1>
    7779          <h2>Settings</h2>
    7880
     
    117119              </tbody>
    118120            </table>
    119             <p class="submit"><input type="submit" class="button button-primary"></p>
     121            <p class="submit"><input type="submit" class="button button-primary" value="Save"></p>
    120122          </form>
    121123
     
    132134                    <input type="submit" class="button button-primary" value="Upload">
    133135                    <span id="upload_progress" class="v3d-upload-progress"></span>
     136                    <span id="upload_status" class="v3d-upload-status"></span>
    134137                  </td>
    135138                </tr>
     
    162165            }
    163166
    164             v3d_redirect_app_list();
     167            v3d_redirect_app();
    165168        } else {
    166169            echo 'Bad request';
     
    183186            }
    184187
    185             v3d_redirect_app_list();
     188            v3d_redirect_app();
    186189        } else {
    187190            echo 'Bad request';
     
    425428
    426429
    427 function v3d_redirect_app_list() {
     430function v3d_redirect_app($app_id=-1) {
     431
     432    $params = '?page=verge3d_app';
     433
     434    if ($app_id > -1) {
     435        $params .= ('&action=edit&app='.$app_id);
     436    }
     437
    428438    ?>
    429439    <script type="text/javascript">
    430           document.location.href="?page=verge3d_app";
     440          document.location.href="<?php echo $params ?>";
    431441    </script>
    432442    <?php
     
    480490        $app_id = $_REQUEST['app'];
    481491    } else {
    482         wp_die();
     492        wp_die('error');
    483493    }
    484494
     
    493503
    494504    if (!empty($_FILES['appfile'])) {
    495         if (strlen($_FILES['appfile']['name']) > 1) {
     505        if (strlen($_FILES['appfile']['name']) > 1 && $_FILES['appfile']['error'] == UPLOAD_ERR_OK) {
    496506            $fullpath = strip_tags(sanitize_text_field($_REQUEST['apppath']));
    497507
     
    503513            $path = dirname($fullpath);
    504514
    505             if (!is_dir($upload_app_dir.'/'.$path)){
     515            if (!is_dir($upload_app_dir.'/'.$path)) {
    506516                mkdir($upload_app_dir.'/'.$path);
    507517            }
    508518
    509519            if (move_uploaded_file($_FILES['appfile']['tmp_name'], $upload_app_dir.'/'.$fullpath)) {
    510                 print_r("ok");
     520                wp_die('ok');
    511521            }
    512522        }
    513523    }
    514524
    515     wp_die();
    516 }
     525    wp_die('error');
     526}
  • verge3d/trunk/css/admin.css

    r2121979 r2173543  
    1515    margin: 20px;
    1616}
     17
     18.v3d-red {
     19    color: red;
     20}
     21
     22.v3d-green {
     23    color: green;
     24}
  • verge3d/trunk/css/main.css

    r1943524 r2173543  
    11.v3d-iframe {
    2   border-width: 0px;
     2    border-width: 0px;
    33}
  • verge3d/trunk/js/admin.js

    r2121979 r2173543  
    11function v3d_handle_uploads(app_id) {
    22    var input = document.getElementById("appfiles");
    3     var progress = document.getElementById("upload_progress");
     3    var progressElem = document.getElementById("upload_progress");
     4    var statusElem = document.getElementById("upload_status");
    45    var progressCounter = 0;
     6    var errorState = false;
    57
    68    function updateProgress() {
    79        progressCounter++;
    8         progress.innerHTML = progressCounter + '/' + input.files.length;
     10        progressElem.innerText = progressCounter + '/' + input.files.length;
     11
     12        if (progressCounter == input.files.length) {
     13
     14            if (errorState) {
     15                statusElem.className = 'v3d-red';
     16                statusElem.innerText = 'Error!';
     17                alert('Error occured during upload: broken connection or maximum file size exceeded.\nPlease check your connection or server upload size limits.');
     18            } else {
     19                statusElem.className = 'v3d-green';
     20                statusElem.innerText = 'Success!';
     21            }
     22
     23        } else {
     24            statusElem.innerText = '';
     25        }
    926    }
    1027
     
    1532
    1633        // prevent upload of Blender and Max files
    17         if (ext == 'blend' || ext == 'max') {
     34        if (ext == 'blend' || ext == 'blend1' || ext == 'max') {
    1835            updateProgress();
    1936            continue;
     
    2744        formData.append("apppath", path);
    2845        formData.append("appfile", file);
     46
    2947        var req = new XMLHttpRequest();
    3048        req.open("POST", ajaxurl);
    3149        req.send(formData);
    3250        req.addEventListener('load', function() {
    33             updateProgress();
     51            if (this.readyState == 4) {
     52                updateProgress();
     53
     54                if (this.status != 200 || this.response != 'ok') {
     55                    errorState = true;
     56                }
     57            }
    3458        });
    3559    }
  • verge3d/trunk/js/woo_product.js

    r2121979 r2173543  
     1(function() {
    12
    2 function v3d_woocommerce_change_param(name, value) {
     3var v3d_woo_product_info_cb = null;
     4
     5function v3d_woo_form_get_quantity(formData) {
     6    var qtyElems = document.body.querySelectorAll('input.qty');
     7
     8    if (qtyElems.length == 0) {
     9        formData.append('quantity', 1);
     10    } else {
     11        for (var i = 0; i < qtyElems.length; i++) {
     12            var qtyElem = qtyElems[i];
     13            formData.append(qtyElem.name, qtyElem.value);
     14        }
     15    }
     16}
     17
     18function v3d_woo_form_get_variation_id(formData) {
     19    var varIdElem = document.body.querySelector('input.variation_id');
     20    formData.append('variation_id', varIdElem ? varIdElem.value : -1);
     21}
     22
     23function v3d_woo_form_get_attributes(formData) {
     24    var attElems = document.body.querySelectorAll('table.variations select');
     25    for (var i = 0; i < attElems.length; i++) {
     26        var attElem = attElems[i];
     27        formData.append(attElem.name, attElem.value);
     28    }
     29}
     30
     31function v3d_woo_get_product_info(callback) {
     32    v3d_woo_product_info_cb = callback;
     33    v3d_woo_request_product_info();
     34}
     35window.v3d_woo_get_product_info = v3d_woo_get_product_info;
     36
     37
     38function v3d_woo_request_product_info() {
    339    var formData = new FormData();
    4     formData.append('action', 'v3d_woocommerce_change_param');
    5     formData.append('v3d_' + name, value);
     40    formData.append('action', 'v3d_woo_get_product_info');
     41    v3d_woo_form_get_quantity(formData);
     42    v3d_woo_form_get_variation_id(formData);
     43    v3d_woo_form_get_attributes(formData);
    644
    745    var req = new XMLHttpRequest();
     
    1149        var response = JSON.parse(req.response);
    1250
    13         switch (name) {
    14         case 'name':
    15             var name_elem = document.querySelector('.product_title.entry-title');
    16             name_elem.innerHTML = response.html;
    17             break;
    18         case 'price':
    19             var price_elem = document.querySelector('p.price');
    20             price_elem.innerHTML = response.html;
    21             break;
    22         case 'sku':
    23             var sku_elem = document.querySelector('.sku_wrapper .sku');
    24             if (sku_elem)
    25                 sku_elem.innerHTML = response.html;
    26             break;
    27         case 'short_description':
    28             var desc_elem = document.querySelector('.woocommerce-product-details__short-description');
    29             if (desc_elem)
    30                 desc_elem.innerHTML = value;//response.html;
    31             break;
    32         case 'debug':
    33             console.log(response.html);
    34             break;
    35         }
     51        if (v3d_woo_product_info_cb)
     52            v3d_woo_product_info_cb(response);
    3653    });
    3754}
    3855
    39 function v3d_woocommerce_get_attribute(name) {
    40     var formData = new FormData();
    41     formData.append('action', 'v3d_woocommerce_get_attribute');
    42     formData.append('v3d_attribute', name);
    4356
    44     var req = new XMLHttpRequest();
    45     req.open('POST', wc_add_to_cart_params.ajax_url);
    46     req.send(formData);
    47     req.addEventListener('load', function() {
    48         var response = JSON.parse(req.response);
    49         console.log(response);
    50     });
    51 }
     57window.addEventListener('load', function() {
     58
     59    var qtyElems = document.body.querySelectorAll('input.qty');
     60    for (var i = 0; i < qtyElems.length; i++)
     61        qtyElems[i].onchange = v3d_woo_request_product_info;
     62
     63    var varFormElem = document.body.querySelector('.variations_form');
     64    if (varFormElem)
     65        varFormElem.woocommerce_variation_has_changed = v3d_woo_request_product_info;
     66
     67});
     68
     69
     70})();
  • verge3d/trunk/order.php

    r2121979 r2173543  
    1111        return;
    1212    }
     13
     14    add_filter('admin_footer_text', 'v3d_replace_footer');
    1315
    1416    $action = (!empty($_REQUEST['action'])) ? sanitize_text_field($_REQUEST['action']) : '';
  • verge3d/trunk/readme.txt

    r2142399 r2173543  
    55Tested up to: 5.2
    66Requires PHP: 5.6
    7 Stable tag: 2.14.0
     7Stable tag: 2.16.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3535== Changelog ==
    3636
     37= 2.16 =
     38* Add WooCommerce integration. Improve application upload interface.
     39
     40= 2.15 =
     41* Verge3D 2.15 version bump.
     42
     43= 2.14 =
     44* Verge3D 2.14 version bump.
     45
    3746= 2.13 =
    3847* Improve application upload speed, fix various issues with server limits.
  • verge3d/trunk/verge3d.php

    r2142399 r2173543  
    44Plugin URI: https://www.soft8soft.com/verge3d
    55Description: Verge3D is the most artist-friendly toolkit for creating interactive web-based experiences. It can be used to create product configurators, 3D presentations, online stores, e-learning apps, 3D portfolios, browser games and more.
    6 Version: 2.14.0
     6Version: 2.16.0
    77Author: Soft8Soft LLC
    88Author URI: https://www.soft8soft.com
     
    1313include plugin_dir_path(__FILE__) . 'file_storage.php';
    1414include plugin_dir_path(__FILE__) . 'order.php';
    15 //include plugin_dir_path(__FILE__) . 'woo_product.php';
     15include plugin_dir_path(__FILE__) . 'woo_product.php';
    1616
    1717
     
    162162        return;
    163163
     164    add_filter('admin_footer_text', 'v3d_replace_footer');
     165
    164166    if (isset($_GET['settings-updated'])) {
    165167        add_settings_error('verge3d_messages', 'verge3d_message', 'Settings Saved', 'updated');
     
    418420}
    419421
     422function v3d_replace_footer() {
     423    echo 'Thank you for using Verge3D! Please refer to this <a href="https://www.soft8soft.com/docs/manual/en/introduction/Wordpress-Plugin.html" target="_blank">page</a> to find out how to use this plugin.';
     424}
     425
  • verge3d/trunk/woo_product.php

    r2121979 r2173543  
    77
    88
    9 function v3d_register_product_type() {
    10     class WC_Product_Verge3D extends WC_Product {
    11         public function __construct($product) {
    12             $this->product_type = 'verge3d';
    13             parent::__construct($product);
    14         }
    15 
    16         public function get_name($context = 'view') {
    17             $name = v3d_get_session_param($this->get_id(), 'name',
    18                 parent::get_name($context));
    19             return $name;
    20         }
    21 
    22         public function get_price($context = 'view') {
    23             $price = v3d_get_session_param($this->get_id(), 'price',
    24                 get_post_meta($this->get_id(), 'v3d_default_price', true));
    25             return $price;
    26         }
    27 
    28         public function get_sku($context = 'view') {
    29             $sku = v3d_get_session_param($this->get_id(), 'sku',
    30                 parent::get_sku($context));
    31             return $sku;
    32         }
    33 
    34         /*
    35         public function is_purchasable() {
    36             return apply_filters('woocommerce_is_purchasable', $this->exists() && ('publish' === $this->get_status() || current_user_can('edit_post', $this->get_id())) && '' !== $this->get_price(), $this);
    37             return apply_filters('woocommerce_is_purchasable', $this->exists() && ('publish' === $this->get_status() || current_user_can('edit_post', $this->get_id())), $this);
    38         }
    39          */
    40     }
    41 }
    42 add_action('init', 'v3d_register_product_type');
    43 
    44 function v3d_add_product_type($types) {
    45     $types['verge3d'] = __('Verge3D product', 'verge3d');
    46     return $types;
    47 }
    48 add_filter('product_type_selector', 'v3d_add_product_type');
    49 
    50 
    519function v3d_product_tab($tabs) {
    5210    $tabs['verge3d'] = array(
    53         'label'  => __('Verge3D Product', 'verge3d'),
     11        'label'  => __('Verge3D', 'verge3d'),
    5412        'target' => 'v3d_product_options',
    5513        'class'  => array('show_if_verge3d'),
    56         'priority' => 10
     14        'priority' => 100
    5715    );
    5816
     
    6624    ?><div class='options_group'><?php
    6725
    68     woocommerce_wp_text_input(
    69         array(
    70             'id' => 'v3d_app_id',
    71             'label' => __('Application ID', 'verge3d'),
    72             'placeholder' => '',
    73             'desc_tip' => 'true',
    74             'description' => __('Enter Verge3D application ID.', 'verge3d'),
    75             'type' => 'text'
    76         )
    77     );
    78 
    79     woocommerce_wp_text_input(
    80         array(
    81             'id' => 'v3d_default_price',
    82             'label' => __('Default Price', 'verge3d'),
    83             'placeholder' => '',
    84             'desc_tip' => 'true',
    85             'description' => __('Enter Verge3D product default price.', 'verge3d'),
    86             'type' => 'text',
    87             'data_type' => 'price'
    88         )
    89     );
    90 
    91     ?></div>
    92     </div><?php
    93 }
    94 add_action('woocommerce_product_data_panels', 'v3d_product_tab_content');
    95 
    96 
    97 function v3d_save_product_settings($post_id) {
    98 
    99     $app_id = $_POST['v3d_app_id'];
    100     if (!empty($app_id)) {
    101         update_post_meta($post_id, 'v3d_app_id', esc_attr($app_id));
    102     }
    103 
    104     $price = $_POST['v3d_default_price'];
    105     if (!empty($price)) {
    106         update_post_meta($post_id, 'v3d_default_price', esc_attr($price));
    107     }
    108 
    109 }
    110 add_action('woocommerce_process_product_meta', 'v3d_save_product_settings');
    111 
    112 
    113 function v3d_product_front() {
    114     global $product;
    115 
    116     if ('verge3d' == $product->get_type()) {
    117         wc_get_template('single-product/add-to-cart/simple.php');
    118     }
    119 }
    120 add_action('woocommerce_single_product_summary', 'v3d_product_front', 30);
    121 
    122 
    123 function v3d_product_image($html) {
    124     global $product;
     26    global $post;
     27
     28    $value = get_post_meta($post->ID, 'v3d_app_id', true);
     29    if (empty($value))
     30        $value = '';
    12531
    12632    $app_posts = get_posts(array(
     
    13036    ));
    13137
    132     if ('verge3d' == $product->get_type() && !empty($app_posts)) {
     38    $options[''] = __('None (select a value)', 'verge3d');
     39
     40    foreach ($app_posts as $app_post)
     41        $options[$app_post->ID] = $app_post->post_title;
     42
     43    woocommerce_wp_select(array(
     44        'id' => 'v3d_app_id',
     45        'label' => __('Application', 'verge3d'),
     46        'options' =>  $options,
     47        'value' => $value,
     48        'desc_tip' => 'true',
     49        'description' => __('Verge3D application which will be displayed on the product page.', 'verge3d'),
     50    ));
     51
     52    ?></div>
     53    </div><?php
     54}
     55add_action('woocommerce_product_data_panels', 'v3d_product_tab_content');
     56
     57
     58function v3d_save_product_settings($post_id) {
     59
     60    $app_id = $_POST['v3d_app_id'];
     61    if (empty($app_id))
     62        $app_id = '';
     63
     64    update_post_meta($post_id, 'v3d_app_id', esc_attr($app_id));
     65
     66}
     67add_action('woocommerce_process_product_meta', 'v3d_save_product_settings');
     68
     69
     70function v3d_product_image($html) {
     71    global $product;
     72
     73    $app_posts = get_posts(array(
     74        'posts_per_page'   => -1,
     75        'post_type'        => 'v3d_app',
     76        'post_status'      => 'publish',
     77    ));
     78
     79    if (!empty($app_posts)) {
    13380        $app_id = get_post_meta($product->get_id(), 'v3d_app_id', true);
    13481        if (!empty($app_id) && !empty(get_post($app_id)))
    13582            return v3d_gen_app_iframe_html($app_id);
    13683        else
    137             return v3d_gen_app_iframe_html($app_posts[0]->ID);
     84            return $html;
    13885    } else
    13986        return $html;
     
    14289
    14390
    144 function v3d_product_admin_custom_js() {
    145     if ('product' != get_post_type()) :
    146         return;
    147     endif;
    148     ?>
    149     <script type='text/javascript'>
    150         jQuery(document).ready(function () {
    151             //jQuery('.general_options').addClass('show_if_verge3d').show();
    152             //jQuery('#general_product_data').addClass('show_if_verge3d').show();
    153             //jQuery('.pricing').addClass('show_if_verge3d').show();
    154 
    155             // enable Inventory tab
    156             jQuery('.inventory_options').addClass('show_if_verge3d').show();
    157             jQuery('#inventory_product_data ._manage_stock_field').addClass('show_if_verge3d').show();
    158             jQuery('#inventory_product_data ._sold_individually_field').parent().addClass('show_if_verge3d').show();
    159             jQuery('#inventory_product_data ._sold_individually_field').addClass('show_if_verge3d').show();
    160         });
    161     </script>
    162     <?php
    163 }
    164 add_action('admin_footer', 'v3d_product_admin_custom_js');
    165 
    166 
    167 function v3d_set_session_param($product_id, $name, $value) {
    168 
    169     $arr_name = 'v3d_'.$name.'s';
    170 
    171     if (empty(WC()->session))
    172         WC()->initialize_session();
    173 
    174     if (!empty(WC()->session->get($arr_name)))
    175         $params = WC()->session->get($arr_name);
    176     else
    177         $params = array();
    178 
    179     $params[$product_id] = $value;
    180     WC()->session->set($arr_name, $params);
    181 }
    182 
    183 function v3d_get_session_param($product_id, $name, $default_value='') {
    184 
    185     $arr_name = 'v3d_'.$name.'s';
    186 
    187     if (empty(WC()->session))
    188         WC()->initialize_session();
    189 
    190     if (!empty(WC()->session->get($arr_name)))
    191         $params = WC()->session->get($arr_name);
    192     else
    193         $params = array();
    194 
    195     if (!empty($params[$product_id]))
    196         return $params[$product_id];
    197     else
    198         return $default_value;
    199 }
    200 
    201 function v3d_unset_session_param($product_id, $name) {
    202 
    203     $arr_name = 'v3d_'.$name.'s';
    204 
    205     if (!empty(WC()->session->get($arr_name))) {
    206         $params = WC()->session->get($arr_name);
    207         unset($params[$product_id]);
    208         WC()->session->set($arr_name, $params);
     91function v3d_parse_request_attributes() {
     92
     93    $attrs = array();
     94
     95    foreach ($_REQUEST as $key => $value) {
     96        if (strpos($key, 'attribute_') !== false)
     97          $attrs[str_replace('attribute_', '', $key)] = $value;
    20998    }
    210 }
    211 
    212 function v3d_change_param() {
     99
     100    return $attrs;
     101}
     102
     103function v3d_product_get_attributes($product) {
     104    $attrs = array();
     105
     106    // NOTE: using get_attributes() alone does not work
     107    foreach ($product->get_attributes() as $attr_key => $attr_value) {
     108        $attrs[$attr_key] = $product->get_attribute($attr_key);
     109    }
     110
     111    return $attrs;
     112}
     113
     114function v3d_get_product_info() {
    213115
    214116    $url = wp_get_referer();
     
    220122    );
    221123
    222     if (!empty($_REQUEST['v3d_name'])) {
    223         $name = $_REQUEST['v3d_name'];
    224 
    225         v3d_set_session_param($product->get_id(), 'name', $name);
    226         $response['html'] = $name;
     124    if (!empty($product)) {
    227125        $response['status'] = 'ok';
     126
     127        $quantity = $_REQUEST['quantity'];
     128
     129        $response['name'] = $product->get_name();
     130        $response['type'] = $product->get_type();
     131        $response['quantity'] = intval($quantity);
     132
     133        $response['sku'] = $product->get_sku();
     134        $response['price'] = floatval($product->get_price());
     135
     136        $response['weight'] = floatval($product->get_weight());
     137
     138        $response['length'] = floatval($product->get_length());
     139        $response['width'] = floatval($product->get_width());
     140        $response['height'] = floatval($product->get_height());
     141
     142        $response['attributes'] = v3d_product_get_attributes($product);
     143
     144        if ($product->is_type('variable')) {
     145
     146            // preserving non-variable attributes
     147            foreach (v3d_parse_request_attributes() as $attr_key => $attr_value) {
     148                $response['attributes'][$attr_key] = $attr_value;
     149            }
     150
     151            if (!empty($_REQUEST['variation_id'])) {
     152                $variation = wc_get_product($_REQUEST['variation_id']);
     153
     154                $response['name'] = $variation->get_name();
     155
     156                if (!empty($variation->get_sku()))
     157                    $response['sku'] = $variation->get_sku();
     158                if (!empty($variation->get_price()))
     159                    $response['price'] = floatval($variation->get_price());
     160
     161                if (!empty($variation->get_weight()))
     162                    $response['weight'] = floatval($variation->get_weight());
     163
     164                if (!empty($variation->get_length()))
     165                    $response['length'] = floatval($variation->get_length());
     166                if (!empty($variation->get_width()))
     167                    $response['width'] = floatval($variation->get_width());
     168                if (!empty($variation->get_height()))
     169                    $response['height'] = floatval($variation->get_height());
     170             }
     171
     172        } else if ($product->is_type('grouped')) {
     173
     174            unset($response['price']);
     175            unset($response['quantity']);
     176            unset($response['weight']);
     177            unset($response['length']);
     178            unset($response['width']);
     179            unset($response['height']);
     180
     181            $response['children'] = array();
     182
     183            foreach ($product->get_children() as $child_id) {
     184                $child = wc_get_product($child_id);
     185                $child_response = array();
     186
     187                $child_response['name'] = $child->get_name();
     188                $child_response['quantity'] = intval($quantity[$child_id]);
     189
     190                $child_response['sku'] = $child->get_sku();
     191                $child_response['price'] = floatval($child->get_price());
     192
     193                $child_response['weight'] = floatval($child->get_weight());
     194
     195                $child_response['length'] = floatval($child->get_length());
     196                $child_response['width'] = floatval($child->get_width());
     197                $child_response['height'] = floatval($child->get_height());
     198
     199                $child_response['attributes'] = v3d_product_get_attributes($child);
     200
     201                array_push($response['children'], $child_response);
     202            }
     203
     204        }
     205
    228206    }
    229207
    230     if (!empty($_REQUEST['v3d_price'])) {
    231         $price = $_REQUEST['v3d_price'];
    232 
    233         v3d_set_session_param($product->get_id(), 'price', $price);
    234         $response['html'] = wc_price($price) . $product->get_price_suffix();
    235         $response['status'] = 'ok';
    236     }
    237 
    238     if (!empty($_REQUEST['v3d_sku'])) {
    239         $sku = $_REQUEST['v3d_sku'];
    240 
    241         v3d_set_session_param($product->get_id(), 'sku', $sku);
    242         $response['html'] = $sku;
    243         $response['status'] = 'ok';
    244     }
    245 
    246     if (!empty($_REQUEST['v3d_short_description'])) {
    247         $desc = $_REQUEST['v3d_short_description'];
    248 
    249         v3d_set_session_param($product->get_id(), 'short_description', $desc);
    250         $response['html'] = $desc;
    251         $response['status'] = 'ok';
    252     }
    253 
    254     if (!empty($_REQUEST['v3d_debug'])) {
    255         $response['html'] = '"'.$product.'"';
    256         $response['status'] = 'ok';
    257     }
    258 
    259208    wp_send_json($response);
    260209}
    261 add_action('wp_ajax_v3d_woocommerce_change_param', 'v3d_change_param');
    262 add_action('wp_ajax_nopriv_v3d_woocommerce_change_param', 'v3d_change_param');
    263 
    264 
    265 function v3d_get_attribute() {
    266 
    267     $url = wp_get_referer();
    268     $post_id = url_to_postid($url);
    269     $product = wc_get_product($post_id);
    270 
    271     $response = array(
    272         'status' => 'error'
    273     );
    274 
    275     if (!empty($_REQUEST['v3d_attribute'])) {
    276         $name = $_REQUEST['v3d_attribute'];
    277 
    278         $response['name'] = $name;
    279         $response['value'] = $product->get_attribute($name);
    280         $response['status'] = 'ok';
    281     }
    282 
    283     wp_send_json($response);
    284 }
    285 add_action('wp_ajax_v3d_woocommerce_get_attribute', 'v3d_get_attribute');
    286 add_action('wp_ajax_nopriv_v3d_woocommerce_get_attribute', 'v3d_get_attribute');
     210add_action('wp_ajax_v3d_woo_get_product_info', 'v3d_get_product_info');
     211add_action('wp_ajax_nopriv_v3d_woo_get_product_info', 'v3d_get_product_info');
Note: See TracChangeset for help on using the changeset viewer.