Title: Overwrite values
Last modified: February 4, 2021

---

# Overwrite values

 *  Resolved [ilyapokrov](https://wordpress.org/support/users/ilyapokrov/)
 * (@ilyapokrov)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/overwrite-values/)
 * For many days I have been racking my brains over how to solve one problem, but
   nothing happens =)
    Can you tell me the code I need to use? There are goods that
   are divided into 3 values: “Adults”, “Children”, “Babies”. In turn, these products
   have gender, but the file is not specified correctly, like this:
 * <param name=”Age”> – “Adults”, “Children”, “Babies”
    <param name=”gender”> – “
   male”, “female”, “None”
 * “Adults” – “male”, “female”
    “Children” – “male” “Babies” – “None”
 * How to write code like this so that:
    If the product is “Adults”, then write 
   down what is indicated in the file, if the product is “children” or the product“
   Babies”, then write down this value – “For girls | For boys”
 * > I understand that I am not going too far when I ask you to help me, nevertheless
   > I really hope that you can tell =)
 * My code is half working. Products for children still have the meaning “for male”:
 * `[my_map_data({param[@name="gender"]})]`
 *     ```
       ///////////* Gender Attribute*/
       function my_map_data( $data ) {
           $map = array(
       		'male' => 'for male',
       		'female' => 'for female',
       		'None' => 'for girls|for boys',
           );
           return ( array_key_exists( $data, $map ) ) ? $map[ $data ] : $data;
       }
       ```
   
    -  This topic was modified 5 years, 4 months ago by [ilyapokrov](https://wordpress.org/support/users/ilyapokrov/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/overwrite-values/#post-14026503)
 * Hi [@ilyapokrov](https://wordpress.org/support/users/ilyapokrov/),
 * You’d need to pass both the gender and the age to your function like this:
 * `[my_parse_data({param[@name="Age"]},{param[@name="gender"]})]`
 * Then, process the data in the function. Here is an untested example that you 
   can modify as needed:
 *     ```
       function my_parse_data( $age, $gender ) {
           $age    = strtolower( $age );
           $gender = strtolower( $gender );
   
           if ( $age == 'adults' ) {
               return 'for ' . $gender;
           } elseif ( $age == 'babies' || $age == 'children' ) {
               return 'For girls | For boys';
           } else {
               if ( $gender == 'none' ) {
                   return 'for girls|for boys';
               }
           }   
   
           return 'for ' . $gender;
       }
       ```
   
 *  Thread Starter [ilyapokrov](https://wordpress.org/support/users/ilyapokrov/)
 * (@ilyapokrov)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/overwrite-values/#post-14026739)
 * [@wpallimport](https://wordpress.org/support/users/wpallimport/),
    That’s what
   I need! Many thanks! Thank you very much!
 *  Thread Starter [ilyapokrov](https://wordpress.org/support/users/ilyapokrov/)
 * (@ilyapokrov)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/overwrite-values/#post-14035934)
 * [@wpallimport](https://wordpress.org/support/users/wpallimport/),
    But what to
   do when you need to use the previously obtained value using a formula? For example,
   I rewritten using the “Category” function, and in order to determine the “size”
   attribute I need to use the resulting category. I have already written the code,
   checked it – it works. But I cannot display it in the attribute. Tried it like
   this: Get a category `[my_map_data_Category({typePrefix[1]})]`
 * Get the attribute
    `[my_map_data_Size({param[@name="Size"]},[my_map_data_Category({
   typePrefix[1]})])]`
 *  Thread Starter [ilyapokrov](https://wordpress.org/support/users/ilyapokrov/)
 * (@ilyapokrov)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/overwrite-values/#post-14039625)
 * [@wpallimport](https://wordpress.org/support/users/wpallimport/),
 * After several attempts, I still managed to achieve the result =)
    I wrote down
   the formula as follows: `[my_map_data_Size({param[@name="Size"]},my_map_data_Category({
   typePrefix[1]}))]`
 * There is also a drawback of this method – a very long catalog update. Apparently
   such formulas slow down the update process very much.
    -  This reply was modified 5 years, 4 months ago by [ilyapokrov](https://wordpress.org/support/users/ilyapokrov/).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Overwrite values’ is closed to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [ilyapokrov](https://wordpress.org/support/users/ilyapokrov/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/overwrite-values/#post-14039625)
 * Status: resolved