Changeset 3173481
- Timestamp:
- 10/22/2024 09:19:53 AM (5 months ago)
- Location:
- printess-editor/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
printess-editor/trunk/printess.php
r3172716 r3173481 5 5 * Plugin URI: https://printess.com/kb/integrations/woo-commerce/index.html 6 6 * Developer: Bastian Kröger ([email protected]); Alexander Oser ([email protected]) 7 * Version: 1.6.2 67 * Version: 1.6.27 8 8 * Author: Printess 9 9 * Author URI: https://printess.com … … 13 13 * Requires PHP: 8.1 14 14 * 15 * Woo: 10000:92398 8dfsfhsf8429842384wdff234sfd15 * Woo: 10000:923989dfsfhsf8429842384wdff234sfd 16 16 * WC requires at least: 5.8 17 17 * WC tested up to: 9.3.3 … … 4155 4155 } 4156 4156 4157 /*** 4158 * Returns a lookup for product option names and the correponding slug. 4159 * @param mixed $product The woocmmerce product object (wp post). 4160 * 4161 * @return array Associative array that can be used as lookup for product option name -> slug 4162 */ 4163 function printess_get_product_options_and_slugs($product) { 4164 $productAttributes = printess_get_product_attributes( $product ); 4165 $ret = array(); 4166 4167 foreach ( $product->get_attributes() as $key => $attribute ) { 4168 if(is_string($attribute)) { 4169 if(array_key_exists($key, $productAttributes) ) { 4170 $ret[$attribute] = $key; 4171 } 4172 } else { 4173 if(method_exists($attribute, "get_data")) { 4174 $data = $attribute->get_data(); 4175 4176 if(array_key_exists("name", $data)) { 4177 $ret[$data["name"]] = $key; 4178 } 4179 } 4180 } 4181 } 4182 4183 return $ret; 4184 } 4185 4157 4186 /** 4158 4187 * Saves a design after login in case the user has not been logged in before … … 4196 4225 printess_unexpire_save_token( $save_token, printess_create_new_unexpiration_date() ); 4197 4226 4198 $design_id = $repo->add_design( $user_id, $save_token, $thumbnail_url, intval( '' . $product_id ), $product->get_data()['name'], $display_name, json_decode( stripslashes( $options ), true ) ); 4227 $product_options = json_decode( stripslashes( $options ), true ); 4228 $product_attributes = printess_get_product_options_and_slugs($product); 4229 $variant_options = array(); 4230 4231 if ( isset( $product_options ) && !empty($options) ) { 4232 foreach ( $product_options as $key => $value ) { 4233 if ( strpos( $key, 'attribute_' ) === 0 ) { 4234 $variant_options[$key] = $value; 4235 } else if(array_key_exists($key, $product_attributes)) { 4236 $variant_options["attribute_" . $product_attributes[$key]] = $value; 4237 } 4238 } 4239 } 4240 4241 $design_id = $repo->add_design( $user_id, $save_token, $thumbnail_url, intval( '' . $product_id ), $product->get_data()['name'], $display_name, $variant_options); 4199 4242 4200 4243 $design = $repo->get_design( $user_id, $design_id ); … … 4206 4249 $product_url = add_query_arg( 'design_id', '' . $design['id'], $product_url ); 4207 4250 4208 if ( null !== $options && '' !== $options ) { 4209 try { 4210 $options = json_decode( stripslashes( $options ), true ); 4211 4212 if ( isset( $options ) ) { 4213 foreach ( $options as $key => $value ) { 4214 if ( strpos( $key, 'attribute_' ) === 0 ) { 4215 $product_url = $product_url . '&' . rawurlencode( $key ) . '=' . rawurlencode( $value ); 4216 } 4217 } 4218 } 4219 } catch ( \Exception $ex ) { 4220 // In case json is invalid, just ignore it. 4221 } 4251 foreach ( $variant_options as $key => $value ) { 4252 $product_url = $product_url . '&' . rawurlencode( $key ) . '=' . rawurlencode( $value ); 4222 4253 } 4223 4254 … … 4226 4257 } 4227 4258 } catch ( Exception $ex ) { 4228 4229 } 4230 4231 4259 return $redirect; 4260 } 4261 4262 return $redirect; 4232 4263 } 4233 4264 -
printess-editor/trunk/readme.txt
r3172716 r3173481 207 207 = 1.6.26 = 208 208 * Added: Added support for dropship variables without having to create template form fields 209 210 = 1.6.27 = 211 * Fixed: Fixed broken variant handling during saving of designs while not being logged in (variant settings got lost during the login process when saving a design)
Note: See TracChangeset
for help on using the changeset viewer.