[COLOR=#444444][FONT=Open Sans]Hallo,
ich möchte in meinem woocommerce shop zusätzliche Variablen eingeben, die noch weitere Infos zum Produkt ausgeben. unter anderem auch ein Feld, wo man "preis pro kg" eintragen kann. Das soll dann in der Shopseite neben dem tatsächlichen preis stehen. Ich habe ein Code Schnipsel gefunden, der mir zumindest schon ein neues Feld zu den variablen Produktfeldern hinzufügt. Das funktioniert super. leider weiß ich nicht wie ich ein weiteres Feld hinzufügen kann, da ich zwei benötige. Ich bin programmiertechnisch nicht so fit die Funktion zu erweitern. Zusätzlich würde ich die eingegebnen Werte dann gerne auf der Produktseite ausgeben.[/FONT][/COLOR]
[COLOR=#444444][FONT=Open Sans]Kann mir jeman helfen? Die Funktion sieht folgendermaßen aus:
[/FONT][/COLOR]
[COLOR=#888888][FONT=monospace]//Display Fieldsadd_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 );//JS to add fields for new variationsadd_action( 'woocommerce_product_after_variable_attributes_js', 'variable_fields_js' );//Save variation fieldsadd_action( 'woocommerce_process_product_meta_variable', 'variable_fields_process', 10, 1 );function variable_fields( $loop, $variation_data ) {?><tr><td><div><label><?php _e( 'My Custom Field', 'woocommerce' ); ?></label><input type="text" size="5" name="my_custom_field[<?php echo $loop; ?>]" value="<?php echo $variation_data['_my_custom_field'][0]; ?>"/></div></td></tr><?php}function variable_fields_js() {?><tr>\<td>\<div>\<label><?php _e( 'My Custom Field', 'woocommerce' ); ?></label>\<input type="text" size="5" name="my_custom_field[' + loop + ']" />\</div>\</td>\</tr>\<?php}function variable_fields_process( $post_id ) {if (isset( $_POST['variable_sku'] ) ) :$variable_sku = $_POST['variable_sku'];$variable_post_id = $_POST['variable_post_id'];$variable_custom_field = $_POST['my_custom_field'];for ( $i = 0; $i < sizeof( $variable_sku ); $i++ ) :$variation_id = (int) $variable_post_id[$i];if ( isset( $variable_custom_field[$i] ) ) {update_post_meta( $variation_id, '_my_custom_field', stripslashes( $variable_custom_field[$i] ) );}endfor;endif;}[/FONT][/COLOR]
[COLOR=#444444][FONT=Open Sans]
[/FONT][/COLOR]