Changeset 2399878
- Timestamp:
- 10/15/2020 02:14:51 AM (5 years ago)
- Location:
- doshii
- Files:
-
- 2 added
- 7 edited
-
tags/2.2.0 (added)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/doshii_function.php (modified) (3 diffs)
-
trunk/include/woo-doshii-import-export.php (added)
-
trunk/include/woo-doshii-initialise.php (modified) (1 diff)
-
trunk/include/woo-doshii-item-dropdown.php (modified) (7 diffs)
-
trunk/include/woo-doshii-product-sync.php (modified) (1 diff)
-
trunk/include/woo-order-api.php (modified) (4 diffs)
-
trunk/include/woo-order-status.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
doshii/trunk/README.txt
r2398260 r2399878 5 5 Requires at least: 4.7 6 6 Tested up to: 5.5.1 7 Stable tag: 2. 1.17 Stable tag: 2.2.0 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 60 60 == Changelog == 61 61 62 = 2.2.0 = 63 64 Improved support for bulk menu mapping 65 62 66 = 2.1.1 = 63 67 -
doshii/trunk/doshii_function.php
r2398260 r2399878 7 7 Author URI: 8 8 Contributors: 9 Version: 2. 1.19 Version: 2.2.0 10 10 */ 11 11 … … 30 30 31 31 register_activation_hook( __FILE__, 'doshii_on_activation' ); 32 wp_enqueue_style( 'doshiistyle', DOSHII_BASE_URL . 'include/assets/css/doshii-style.css',false,'2. 1.1','all');32 wp_enqueue_style( 'doshiistyle', DOSHII_BASE_URL . 'include/assets/css/doshii-style.css',false,'2.2.0','all'); 33 33 include(DOSHII_BASE_DIR . '/include/woo-doshii-dbtable.php'); 34 34 include(DOSHII_BASE_DIR . '/include/woo-checkout-fields.php'); … … 39 39 include(DOSHII_BASE_DIR . '/include/settings.php'); 40 40 include(DOSHII_BASE_DIR . '/include/woo-doshii-initialise.php'); 41 include(DOSHII_BASE_DIR . '/include/woo-doshii-import-export.php'); 41 42 include(DOSHII_BASE_DIR . '/include/woo-doshii-item-dropdown.php'); 42 43 include(DOSHII_BASE_DIR . '/include/woo-order-status.php'); -
doshii/trunk/include/woo-doshii-initialise.php
r2398260 r2399878 39 39 'x-doshii-location-id' => $locationId.'', 40 40 'content-Type' => 'application/json', 41 'x-doshii-writeout' => 'WooCommerce 2. 1.1',41 'x-doshii-writeout' => 'WooCommerce 2.2.0', 42 42 ) 43 43 )); -
doshii/trunk/include/woo-doshii-item-dropdown.php
r2386799 r2399878 9 9 global $product_object, $post, $product; 10 10 11 $_product = wc_get_product( $post->ID );12 11 $doshii_product_tbl = $wpdb->prefix . 'doshii_product'; 13 12 $doshii_sql = "SELECT * FROM $doshii_product_tbl"; 14 13 $doshii_results = $wpdb->get_results($doshii_sql) or array(); 15 14 if (!empty($doshii_results)) { 16 $product_ids = $product_object->get_meta( '_doshii_posId' );15 $product_ids = $product_object->get_meta( '_doshii_posId' ); 17 16 ?> 18 17 … … 23 22 <option value="">Select Doshii Product</option> 24 23 <?php 24 $productId = is_array($product_ids) ? $product_ids[0] : $product_ids; 25 25 foreach ( $doshii_results as $product_id ) { 26 26 $selected=''; 27 if($product _ids[0]== $product_id->doshii_product_id){ $selected = selected( true, true, false ); }27 if($productId == $product_id->doshii_product_id){ $selected = selected( true, true, false ); } 28 28 echo '<option '.$selected.' value="' . esc_attr( $product_id->doshii_product_id ) . '">' . wp_kses_post( $product_id->doshii_product_name) . '</option>'; 29 29 } … … 34 34 <?php 35 35 $doshii_product_option_tbl = $wpdb->prefix . 'doshii_product_option'; 36 $doshii_option_sql = "SELECT * FROM $doshii_product_option_tbl where doshii_product_id='$product _ids[0]'";36 $doshii_option_sql = "SELECT * FROM $doshii_product_option_tbl where doshii_product_id='$productId'"; 37 37 $doshii_option_results = $wpdb->get_results($doshii_option_sql); 38 38 $product_option_ids = $product_object->get_meta( '_doshii_option_posId' ); 39 $optionId = is_array($product_option_ids) ? $product_option_ids[0] : $product_option_ids; 39 40 ?> 40 41 41 <p style="<?php if($ product_option_ids[0]!=''){ echo 'display:block'; }else{ echo 'display:none'; } ?>" class="form-field doshii_option_posId">42 <p style="<?php if($optionId !=''){ echo 'display:block'; }else{ echo 'display:none'; } ?>" class="form-field doshii_option_posId"> 42 43 <label for="subscription_toggle_products"><?php _e( 'Doshii Product Option', 'woocommerce' ); ?></label> 43 44 … … 46 47 <?php 47 48 foreach($doshii_option_results as $options){ 48 if ( in_array($options->doshii_product_option_id, $product_option_ids)) {49 if ($options->doshii_product_option_id === $optionId) { 49 50 $selected = selected( true, true, false ); 50 51 echo '<option '.$selected.' value="' . esc_attr( $options->doshii_product_option_id ) . '">' . wp_kses_post( $options->doshii_product_option_name) . '</option>'; 51 52 } else { 52 echo '<option '.$selected.'value="' . esc_attr( $options->doshii_product_option_id ) . '">' . wp_kses_post( $options->doshii_product_option_name) . '</option>';53 echo '<option value="' . esc_attr( $options->doshii_product_option_id ) . '">' . wp_kses_post( $options->doshii_product_option_name) . '</option>'; 53 54 } 54 55 } … … 57 58 </p> 58 59 59 <?php $product_variant_ids = $product_object->get_meta( '_doshii_variant_posId' ); ?> 60 <?php 61 $product_variant_ids = $product_object->get_meta( '_doshii_variant_posId' ); 62 $variantId = is_array($product_variant_ids) ? $product_variant_ids[0] : $product_variant_ids; 63 ?> 60 64 61 <p style="<?php if($ product_variant_ids[0]!=''){ echo 'display:block'; }else{ echo 'display:none'; } ?>" class="form-field doshii_variant_posId">65 <p style="<?php if($variantId !=''){ echo 'display:block'; }else{ echo 'display:none'; } ?>" class="form-field doshii_variant_posId"> 62 66 <label for="subscription_toggle_products"><?php _e( 'Doshii Product Variant', 'woocommerce' ); ?></label> 63 67 <select readonly multiple="multiple" id="doshii_variant_posId" name="_doshii_variant_posId[]"> … … 67 71 $finalOption=[]; 68 72 $doshii_product_variant_tbl = $wpdb->prefix . 'doshii_product_variant'; 69 $doshii_variant_sql = "SELECT * FROM $doshii_product_variant_tbl where doshii_product_id='$product _ids[0]' AND doshii_product_option_id='$product_option_ids[0]'";73 $doshii_variant_sql = "SELECT * FROM $doshii_product_variant_tbl where doshii_product_id='$productId' AND doshii_product_option_id='$optionId'"; 70 74 $doshii_variant_results = $wpdb->get_results($doshii_variant_sql); 71 75 72 76 foreach($doshii_variant_results as $Variantdata){ 73 if ( in_array($Variantdata->doshii_product_variant_id, $product_variant_ids)){77 if ($Variantdata->doshii_product_variant_id === $variantId) { 74 78 $selected = selected( true, true, false ); 75 79 echo '<option '.$selected.' value="' . esc_attr( $Variantdata->doshii_product_variant_id ) . '">' . wp_kses_post( $Variantdata->doshii_product_variant_name) . '</option>'; 76 } else{80 } else { 77 81 echo '<option value="' . esc_attr( $Variantdata->doshii_product_variant_id ) . '">' . wp_kses_post( $Variantdata->doshii_product_variant_name) . '</option>'; 78 82 } … … 91 95 add_action( 'woocommerce_admin_process_product_object', 'save_linked_products_data_custom_field_value', 10, 1 ); 92 96 function save_linked_products_data_custom_field_value( $product ) { 93 $data = isset( $_POST['_doshii_posId'] ) ? array_map( 'strval', (array) $_POST['_doshii_posId'] ) : array();97 $data = isset( $_POST['_doshii_posId'] ) ? $_POST['_doshii_posId'] : ''; 94 98 $product->update_meta_data( '_doshii_posId', $data ); 95 99 96 $Optiondata = isset( $_POST['_doshii_option_posId'] ) ? array_map( 'strval', (array) $_POST['_doshii_option_posId'] ) : array();100 $Optiondata = isset( $_POST['_doshii_option_posId'] ) ? $_POST['_doshii_option_posId'] : ''; 97 101 $product->update_meta_data( '_doshii_option_posId', $Optiondata ); 98 102 99 $Variantdata = isset( $_POST['_doshii_variant_posId'] ) ? array_map( 'strval', (array) $_POST['_doshii_variant_posId'] ) : array();103 $Variantdata = isset( $_POST['_doshii_variant_posId'] ) ? $_POST['_doshii_variant_posId'] : ''; 100 104 $product->update_meta_data( '_doshii_variant_posId', $Variantdata ); 101 105 } 106 107 add_filter( 'manage_edit-product_columns', 'doshii_show_product_id',15 ); 108 function doshii_show_product_id($columns) { 109 110 //add column 111 $updatedColumns = array_slice($columns, 0, count($columns) - 1, true) + 112 array('doshii_product_map' => __('Doshii Product ID', 'doshii')) + 113 array_slice($columns, count($columns) - 1, NULL, true); 114 115 return $updatedColumns; 116 } 117 118 add_action( 'manage_product_posts_custom_column', 'doshii_populate_doshii_product_map', 10, 2 ); 119 function doshii_populate_doshii_product_map( $column, $postid ) { 120 if ($column == 'doshii_product_map') { 121 $productIds = get_post_meta( $postid, '_doshii_posId', true); 122 123 $productId = isset($productIds) ? (is_array($productIds) ? $productIds[0] : $productIds) : ''; 124 if (!empty($productId)) { 125 $optionIds = get_post_meta( $postid, '_doshii_option_posId', true); 126 $optionId = ''; 127 $variantId = ''; 128 if (isset($optionIds)) { 129 if (is_array($optionIds)) { 130 $optionId = !empty($optionIds[0]) ? "<br /><span style=\"margin-left: 15px;\">→ {$optionIds[0]}</span>" : ''; 131 } else { 132 $optionId = !empty($optionIds) ? "<br /><span style=\"margin-left: 15px;\">→ {$optionIds}</span>" : ''; 133 } 134 135 $variantIds = get_post_meta( $postid, '_doshii_variant_posId', true); 136 if (isset($variantIds)) { 137 if (is_array($variantIds)) { 138 $variantId = !empty($variantIds[0]) ? "<br /><span style=\"margin-left: 32px;\">→ {$variantIds[0]}</span>" : ''; 139 } else { 140 $variantId = !empty($variantIds) ? "<br /><span style=\"margin-left: 32px;\">→ {$variantIds}</span>" : ''; 141 } 142 } 143 } 144 $value = "{$productId}{$optionId}{$variantId}"; 145 } 146 echo (empty($value) ? '-' : $value); 147 } 148 } 102 149 ?> -
doshii/trunk/include/woo-doshii-product-sync.php
r2398260 r2399878 41 41 'x-doshii-location-id' => $locationId.'', 42 42 'content-Type' => 'application/json', 43 'x-doshii-writeout' => 'WooCommerce 2. 1.1',43 'x-doshii-writeout' => 'WooCommerce 2.2.0', 44 44 ) 45 45 )); -
doshii/trunk/include/woo-order-api.php
r2398260 r2399878 166 166 167 167 $mappedProductId = get_post_meta($product_id, '_doshii_posId'); 168 $mappedProductId = count($mappedProductId[0]) > 0 ? $mappedProductId[0][0] : ''; 169 $mappedOptionId = empty($mappedProductId) ? [[]] : get_post_meta($product_id, '_doshii_option_posId'); 170 $mappedOptionId = count($mappedOptionId[0]) > 0 ? $mappedOptionId[0][0] : ''; 168 $mappedProductId = count($mappedProductId) > 0 ? $mappedProductId[0] : ''; 169 $mappedProductId = is_array($mappedProductId) ? $mappedProductId[0] : $mappedProductId; 170 $mappedOptionId = empty($mappedProductId) ? [] : get_post_meta($product_id, '_doshii_option_posId'); 171 $mappedOptionId = count($mappedOptionId) > 0 ? $mappedOptionId[0] : ''; 172 $mappedOptionId = is_array($mappedOptionId) ? $mappedOptionId[0] : $mappedOptionId; 171 173 172 174 $doshiiOptions = []; 173 175 if (!empty($mappedOptionId)) { 174 176 $mappedVariantId = get_post_meta($product_id, '_doshii_variant_posId'); 175 $mappedVariantId = count($mappedVariantId[0]) > 0 ? $mappedVariantId[0][0] : ''; 177 $mappedVariantId = count($mappedVariantId) > 0 ? $mappedVariantId[0] : ''; 178 $mappedVariantId = is_array($mappedVariantId) ? $mappedVariantId[0] : $mappedVariantId; 176 179 177 180 if (!empty($mappedVariantId)) { … … 375 378 } 376 379 377 if (empty($option_posId)) { 378 array_push($doshiiOptions, (object)[ 379 'name' => $option_name, 380 'variants' => $variants 381 ]); 382 } else { 383 array_push($doshiiOptions, (object)[ 384 'posId' => $option_posId, 385 'name' => $option_name, 386 'variants' => $variants 387 ]); 380 // Only add the option if there are variants in the list 381 if (!empty($variants)) { 382 if (empty($option_posId)) { 383 array_push($doshiiOptions, (object)[ 384 'name' => $option_name, 385 'variants' => $variants 386 ]); 387 } else { 388 array_push($doshiiOptions, (object)[ 389 'posId' => $option_posId, 390 'name' => $option_name, 391 'variants' => $variants 392 ]); 393 } 388 394 } 389 395 } … … 480 486 'accept' => 'application/json', 481 487 'Accept-encoding' => 'gzip', 482 'x-doshii-writeout' => 'WooCommerce 2. 1.1',488 'x-doshii-writeout' => 'WooCommerce 2.2.0', 483 489 ), 484 490 'body' => json_encode($doshiiOrderPayload) … … 546 552 return '-'; 547 553 } 554 ?> -
doshii/trunk/include/woo-order-status.php
r2398260 r2399878 39 39 'x-doshii-location-id' => $doshii_options['location_id'].'', 40 40 'content-Type' => 'application/json', 41 'x-doshii-writeout' => 'WooCommerce 2. 1.1',41 'x-doshii-writeout' => 'WooCommerce 2.2.0', 42 42 ) 43 43 ));
Note: See TracChangeset
for help on using the changeset viewer.