• Resolved ady66

    (@ady66)


    There is one line in the xml feed: <gender></gender>
    For each product has a different label, for example: W, M, U, K
    I would need these letters to be automatically transcribed to words: W to form women, M to for men, U to unisex, K to for kids.
    They will appear in Title ans Short description fields.
    I added in Function editor this snippets, but not working. Pls help me. Thank you.

    <?php
    function gender ( $text ) {
        return ( $text == 'W' ) ? 'W' : 'for women';
        return ( $text == 'M' ) ? 'M' : 'for men';
        return ( $text == 'U' ) ? 'U' : 'unisex';
        return ( $text == 'K' ) ? 'K' : 'for kids';
    }
    ?>
    • This topic was modified 5 years, 1 month ago by ady66.
    • This topic was modified 5 years, 1 month ago by ady66.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter ady66

    (@ady66)

    @wpallimport
    Can it be fixed? Thank you.

    Plugin Author WP All Import

    (@wpallimport)

    Hi @ady66

    Please try this function instead:

    function my_gender_func( $text ) {
    	$map = array(
    		'W' => 'for women',
    		'M' => 'for men',
    		'U' => 'unisex',
    		'K' => 'for kids'
    	);
        return ( array_key_exists( $text, $map ) ) ? $map[ $text ] : $text;
    }
    Thread Starter ady66

    (@ady66)

    Hi @wpallimport

    not working with this function, it hasn’t changed. Maybe another solution? Thank you.

    Plugin Author WP All Import

    (@wpallimport)

    @ady66 can you show me how you’re using the function and provide an example import file (1 record)? You can use dummy data in the file, just make sure that the value in the “gender” element is exactly the same as it is in your real data feed.

    Plugin Author WP All Import

    (@wpallimport)

    @ady66 I’m marking this as resolved since we have not heard back. Feel free to follow up here if necessary. Anyone else, please open a new thread.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change Letter to Word’ is closed to new replies.