Changeset 2173543
- Timestamp:
- 10/15/2019 09:02:44 AM (6 years ago)
- Location:
- verge3d/trunk
- Files:
-
- 9 edited
-
app.php (modified) (14 diffs)
-
css/admin.css (modified) (1 diff)
-
css/main.css (modified) (1 diff)
-
js/admin.js (modified) (3 diffs)
-
js/woo_product.js (modified) (2 diffs)
-
order.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
verge3d.php (modified) (4 diffs)
-
woo_product.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
verge3d/trunk/app.php
r2121979 r2173543 2 2 3 3 define('V3D_DEFAULT_CANVAS_WIDTH', 800); 4 define('V3D_DEFAULT_CANVAS_HEIGHT', 600);4 define('V3D_DEFAULT_CANVAS_HEIGHT', 500); 5 5 6 6 if (!class_exists('WP_List_Table')){ … … 15 15 } 16 16 17 add_filter('admin_footer_text', 'v3d_replace_footer'); 18 17 19 $action = (!empty($_REQUEST['action'])) ? sanitize_text_field($_REQUEST['action']) : ''; 18 20 … … 22 24 23 25 <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> 25 27 <form method="get" class="validate"> 26 28 <input type="hidden" name="page" value="<?php echo sanitize_text_field($_REQUEST['page']) ?>" /> … … 36 38 </tbody> 37 39 </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> 39 41 </form> 40 42 </div> … … 54 56 ), 55 57 ); 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); 58 60 break; 59 61 case 'edit': … … 74 76 ?> 75 77 <div class="wrap"> 76 <h1 class="wp-heading-inline"> Update Verge3D Application</h1>78 <h1 class="wp-heading-inline">Manage Verge3D Application</h1> 77 79 <h2>Settings</h2> 78 80 … … 117 119 </tbody> 118 120 </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> 120 122 </form> 121 123 … … 132 134 <input type="submit" class="button button-primary" value="Upload"> 133 135 <span id="upload_progress" class="v3d-upload-progress"></span> 136 <span id="upload_status" class="v3d-upload-status"></span> 134 137 </td> 135 138 </tr> … … 162 165 } 163 166 164 v3d_redirect_app _list();167 v3d_redirect_app(); 165 168 } else { 166 169 echo 'Bad request'; … … 183 186 } 184 187 185 v3d_redirect_app _list();188 v3d_redirect_app(); 186 189 } else { 187 190 echo 'Bad request'; … … 425 428 426 429 427 function v3d_redirect_app_list() { 430 function 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 428 438 ?> 429 439 <script type="text/javascript"> 430 document.location.href=" ?page=verge3d_app";440 document.location.href="<?php echo $params ?>"; 431 441 </script> 432 442 <?php … … 480 490 $app_id = $_REQUEST['app']; 481 491 } else { 482 wp_die( );492 wp_die('error'); 483 493 } 484 494 … … 493 503 494 504 if (!empty($_FILES['appfile'])) { 495 if (strlen($_FILES['appfile']['name']) > 1 ) {505 if (strlen($_FILES['appfile']['name']) > 1 && $_FILES['appfile']['error'] == UPLOAD_ERR_OK) { 496 506 $fullpath = strip_tags(sanitize_text_field($_REQUEST['apppath'])); 497 507 … … 503 513 $path = dirname($fullpath); 504 514 505 if (!is_dir($upload_app_dir.'/'.$path)) {515 if (!is_dir($upload_app_dir.'/'.$path)) { 506 516 mkdir($upload_app_dir.'/'.$path); 507 517 } 508 518 509 519 if (move_uploaded_file($_FILES['appfile']['tmp_name'], $upload_app_dir.'/'.$fullpath)) { 510 print_r("ok");520 wp_die('ok'); 511 521 } 512 522 } 513 523 } 514 524 515 wp_die( );516 } 525 wp_die('error'); 526 } -
verge3d/trunk/css/admin.css
r2121979 r2173543 15 15 margin: 20px; 16 16 } 17 18 .v3d-red { 19 color: red; 20 } 21 22 .v3d-green { 23 color: green; 24 } -
verge3d/trunk/css/main.css
r1943524 r2173543 1 1 .v3d-iframe { 2 border-width: 0px;2 border-width: 0px; 3 3 } -
verge3d/trunk/js/admin.js
r2121979 r2173543 1 1 function v3d_handle_uploads(app_id) { 2 2 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"); 4 5 var progressCounter = 0; 6 var errorState = false; 5 7 6 8 function updateProgress() { 7 9 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 } 9 26 } 10 27 … … 15 32 16 33 // prevent upload of Blender and Max files 17 if (ext == 'blend' || ext == ' max') {34 if (ext == 'blend' || ext == 'blend1' || ext == 'max') { 18 35 updateProgress(); 19 36 continue; … … 27 44 formData.append("apppath", path); 28 45 formData.append("appfile", file); 46 29 47 var req = new XMLHttpRequest(); 30 48 req.open("POST", ajaxurl); 31 49 req.send(formData); 32 50 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 } 34 58 }); 35 59 } -
verge3d/trunk/js/woo_product.js
r2121979 r2173543 1 (function() { 1 2 2 function v3d_woocommerce_change_param(name, value) { 3 var v3d_woo_product_info_cb = null; 4 5 function 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 18 function 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 23 function 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 31 function v3d_woo_get_product_info(callback) { 32 v3d_woo_product_info_cb = callback; 33 v3d_woo_request_product_info(); 34 } 35 window.v3d_woo_get_product_info = v3d_woo_get_product_info; 36 37 38 function v3d_woo_request_product_info() { 3 39 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); 6 44 7 45 var req = new XMLHttpRequest(); … … 11 49 var response = JSON.parse(req.response); 12 50 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); 36 53 }); 37 54 } 38 55 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);43 56 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 } 57 window.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 11 11 return; 12 12 } 13 14 add_filter('admin_footer_text', 'v3d_replace_footer'); 13 15 14 16 $action = (!empty($_REQUEST['action'])) ? sanitize_text_field($_REQUEST['action']) : ''; -
verge3d/trunk/readme.txt
r2142399 r2173543 5 5 Tested up to: 5.2 6 6 Requires PHP: 5.6 7 Stable tag: 2.1 4.07 Stable tag: 2.16.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 35 35 == Changelog == 36 36 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 37 46 = 2.13 = 38 47 * Improve application upload speed, fix various issues with server limits. -
verge3d/trunk/verge3d.php
r2142399 r2173543 4 4 Plugin URI: https://www.soft8soft.com/verge3d 5 5 Description: 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.1 4.06 Version: 2.16.0 7 7 Author: Soft8Soft LLC 8 8 Author URI: https://www.soft8soft.com … … 13 13 include plugin_dir_path(__FILE__) . 'file_storage.php'; 14 14 include plugin_dir_path(__FILE__) . 'order.php'; 15 //include plugin_dir_path(__FILE__) . 'woo_product.php';15 include plugin_dir_path(__FILE__) . 'woo_product.php'; 16 16 17 17 … … 162 162 return; 163 163 164 add_filter('admin_footer_text', 'v3d_replace_footer'); 165 164 166 if (isset($_GET['settings-updated'])) { 165 167 add_settings_error('verge3d_messages', 'verge3d_message', 'Settings Saved', 'updated'); … … 418 420 } 419 421 422 function 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 7 7 8 8 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 51 9 function v3d_product_tab($tabs) { 52 10 $tabs['verge3d'] = array( 53 'label' => __('Verge3D Product', 'verge3d'),11 'label' => __('Verge3D', 'verge3d'), 54 12 'target' => 'v3d_product_options', 55 13 'class' => array('show_if_verge3d'), 56 'priority' => 10 14 'priority' => 100 57 15 ); 58 16 … … 66 24 ?><div class='options_group'><?php 67 25 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 = ''; 125 31 126 32 $app_posts = get_posts(array( … … 130 36 )); 131 37 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 } 55 add_action('woocommerce_product_data_panels', 'v3d_product_tab_content'); 56 57 58 function 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 } 67 add_action('woocommerce_process_product_meta', 'v3d_save_product_settings'); 68 69 70 function 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)) { 133 80 $app_id = get_post_meta($product->get_id(), 'v3d_app_id', true); 134 81 if (!empty($app_id) && !empty(get_post($app_id))) 135 82 return v3d_gen_app_iframe_html($app_id); 136 83 else 137 return v3d_gen_app_iframe_html($app_posts[0]->ID);84 return $html; 138 85 } else 139 86 return $html; … … 142 89 143 90 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); 91 function 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; 209 98 } 210 } 211 212 function v3d_change_param() { 99 100 return $attrs; 101 } 102 103 function 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 114 function v3d_get_product_info() { 213 115 214 116 $url = wp_get_referer(); … … 220 122 ); 221 123 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)) { 227 125 $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 228 206 } 229 207 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 259 208 wp_send_json($response); 260 209 } 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'); 210 add_action('wp_ajax_v3d_woo_get_product_info', 'v3d_get_product_info'); 211 add_action('wp_ajax_nopriv_v3d_woo_get_product_info', 'v3d_get_product_info');
Note: See TracChangeset
for help on using the changeset viewer.