Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author AukeJomm

    (@aukejomm)

    Hello @marekbo12

    Do you have an xml file for me to look at?
    And maybe a product id where this is happening?

    Thread Starter marekbo12

    (@marekbo12)

    @aukejomm I think something with recursion function is wrong here:

    public static function make_shop_taxonomies_string( $product_id, $tax = 'product_cat', $separator = ' > ' ) {
    			$args = array(
    				'taxonomy' => $tax,
    				'orderby'  => 'parent',
    				'order'    => 'DESC',
    			);
    
    			// get the post term ordered with the last child cat first
    			$cats = wp_get_post_terms( $product_id, $tax, $args );
    
    			$result = array();
    
    			if ( count( $cats ) === 0 ) {
    				return '';
    			}
    
    			// anonymous function to get the correct taxonomy string
    			$cat_string = function ( $id ) use ( &$result, &$cat_string, $tax ) {
    				// get the first term
    				$term = get_term_by( 'id', $id, $tax, 'ARRAY_A' );
    
    				// check if the term has a parent
    				if ( $term['parent'] ) {
    					// start the anonymous function again with the parent id
    					$cat_string( $term['parent'] );
    				}
    
    				// add the terms name to the result
    				$result[] = $term['name'];
    			};
    
    			// activate the anonymous function with the first categories term_id
    			$cat_string( $cats[0]->term_id );
    
    			return implode( $separator, $result );
    		}

    in ‘class-wppfm-taxonomies.php’ file.
    Try to return this function in single-product.php and you will notice that the deepest category is omitted.

    • This reply was modified 4 years, 9 months ago by marekbo12.
    Thread Starter marekbo12

    (@marekbo12)

    @aukejomm
    I have a product in the third category level. The function wp_get_post_terms() returns to me an array with three IDs of these categories, but in random order. The recursive function itself omits the last, deepest category.
    For example, this product -> https://babyono.com/produkt/lyzeczka-silikonowa-babys-smile/ is nested in: ‘Aktywne Dziecko > Sztu?ce > ?y?ki’, but the Product Category String parameter only shows ‘Aktywne Dziecko > Sztu?ce’.

    <item>
    <g:id>1069</g:id>
    <title>
    <![CDATA[ ?y?eczka silikonowa ]]>
    </title>
    <g:description>
    <![CDATA[
    <!-- wp:media-text {"mediaId":6226,"mediaType":"image","isStackedOnMobile":true} --> <div class="wp-block-media-text alignwide is-stacked-on-mobile"><figure class="wp-block-media-text__media"><img src="https://babyono.com/wp-content/uploads/2019/04/1069-Z-1-1024x1024.jpg" alt="" class="wp-image-6226"/></figure><div class="wp-block-media-text__content"><!-- wp:paragraph --> <p>Próba samodzielnego jedzenia to krok milowy w rozwoju ka?dego maluszka. Daj?c swojemu dziecku do r?czek <strong>silikonow? ?y?eczk?</strong>, znacz?co u?atwiasz mu skomplikowane zadanie. Delikatna <strong>?y?eczka silikonowa</strong> zosta?a starannie zaprojektowana w taki sposób, aby dopasowywa? si? do d?oni dziecka. Mi?kki silikon pozbawiony ostrych kraw?dzi nie rani dzi?se? i nie podra?nia podniebienia. ?y?eczka wyprodukowana jest z bezpiecznych i trwa?ych materia?ów pozbawionych substancji, które mog?yby w najmniejszym stopniu wp?yn?? na wra?liwy organizm dziecka.</p> <!-- /wp:paragraph --></div></div> <!-- /wp:media-text --> <!-- wp:media-text {"mediaPosition":"right","mediaId":6266,"mediaType":"image","isStackedOnMobile":true} --> <div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile"><figure class="wp-block-media-text__media"><img src="https://babyono.com/wp-content/uploads/2019/04/1069-Z-2-1024x1024.jpg" alt="" class="wp-image-6266"/></figure><div class="wp-block-media-text__content"><!-- wp:heading --> <h2>W?A?CIWO?CI:</h2> <!-- /wp:heading --> <!-- wp:paragraph --> <p>Delikatna i wygodna</p> <!-- /wp:paragraph --> <!-- wp:list --> <ul><li>ergonomiczny uchwyt, dostosowany do r?czek dziecka</li><li>mi?kki silikon</li><li>zastosowany z my?l? o delikatnych dzi?s?ach dziecka</li><li>idealna podczas nauki samodzielnego jedzenia</li><li>wykonana z trwa?ych i bezpiecznych materia?ów</li><li>nie zawiera Bisfenolu A</li></ul> <!-- /wp:list --> <!-- wp:heading --> <h2>DANE TECHNICZNE:</h2> <!-- /wp:heading --> <!-- wp:paragraph --> <p>W ZESTAWIE:</p> <!-- /wp:paragraph --> <!-- wp:list --> <ul><li>?y?eczka 1szt</li></ul> <!-- /wp:list --></div></div> <!-- /wp:media-text -->
    ]]>
    </g:description>
    <g:google_product_category>
    <![CDATA[ Baby & Toddler ]]>
    </g:google_product_category>
    <g:product_type>Aktywne dziecko > Sztu?ce</g:product_type>
    <link>
    https://babyono.com/produkt/lyzeczka-silikonowa-babys-smile/
    </link>
    <g:image_link>
    https://babyono.com/wp-content/uploads/2019/04/1069-Z-2.jpg
    </g:image_link>
    <g:price>9,49 PLN</g:price>
    <g:condition>new</g:condition>
    <g:availability>in stock</g:availability>
    <g:brand>Babyono</g:brand>
    <g:gtin>5901435407912</g:gtin>
    <g:adult>no</g:adult>
    <g:identifier_exists>yes</g:identifier_exists>
    </item>
    • This reply was modified 4 years, 9 months ago by marekbo12.
    Thread Starter marekbo12

    (@marekbo12)

    @aukejomm Can you help me?

    Plugin Author AukeJomm

    (@aukejomm)

    Hello @marekbo12,

    Yes, I understand.
    I recall we have choosen not to support endless long strings.
    I am not sure why we made that decision and I am waiting for a reply to why that was setup that way.

    I or Michel will reply to your question.

    Thread Starter marekbo12

    (@marekbo12)

    @aukejomm OK, thank you for reply.
    What parameter should I choose to get then: ‘Cat1 > Subcat1 > Subsubcat2’ ?

    Plugin Contributor Michel Jongbloed

    (@michel-jongbloed)

    Hi @marekbo12,

    If I’m not mistaken you’re using a non English taxonomy list. You probably changed the taxonomy.en-US.txt file in the includes/application/google folder. No problem of course, but I think that the character set you’re using is causing this issue. When I use the standard English taxonomy list it works fine.

    Could you send me your taxonomy file to michel @ wpmarketingrobot.com so I can check that file out and see if I can do something to get it working for you?

    Thread Starter marekbo12

    (@marekbo12)

    Hi @michel-jongbloed

    I didn’t change the taxonomy.en-US.txt file.
    I tried to write my own functions sorting categories and subcategories and there was always the same problem (so your recursive function is correct). In fact, usually this problem occurred with non-english words, but polish alphabet is based on utf-8, so I don’t know why it is a problem.
    Which file exactly do you need?

    Plugin Contributor Michel Jongbloed

    (@michel-jongbloed)

    No sorry @marekbo12, You indeed didn’t change the taxonomy file. I was looking at it from an incorrect angle.

    I added the ‘Aktywne Dziecko > Sztu?ce > ?y?ki’ categories to my WP test shop, added a product to that category and added that to the feed. I got

    <item>
    <title>
    <![CDATA[ Plain Braces ]]>
    </title>
    <g:google_product_category>
    <![CDATA[
    Apparel & Accessories > Clothing Accessories > Baby & Toddler Clothing Accessories > Baby & Toddler Belts
    ]]>
    </g:google_product_category>
    <g:product_type>Aktywne Dziecko > Sztu?ce > ?y?ki</g:product_type>
    <link>https://wppfmdebugshop.test/product/plain-braces/</link>
    <g:price>3,50 USD</g:price>
    <g:condition>new</g:condition>
    <g:availability>in stock</g:availability>
    <g:adult>no</g:adult>
    <g:multipack>no</g:multipack>
    <g:identifier_exists>yes</g:identifier_exists>
    <g:is_bundle>2</g:is_bundle>
    <g:shipping>
    <g:country>US</g:country>
    <g:region>MO</g:region>
    <g:service>Over land</g:service>
    <g:price>6.49 USD</g:price>
    </g:shipping>
    <g:shipping>
    <g:country>US</g:country>
    <g:region>MA</g:region>
    <g:service>Express</g:service>
    <g:price>15.99 USD</g:price>
    </g:shipping>
    </item>

    So it seems to work correctly on my server. This also worked for english words, like

    <item>
    <g:id>woo-hoodie</g:id>
    <title>
    <![CDATA[ Hoodie ]]>
    </title>
    <g:description>
    <![CDATA[ This is a variable product. ]]>
    </g:description>
    <g:google_product_category>
    <![CDATA[
    Apparel & Accessories > Clothing Accessories > Baby & Toddler Clothing Accessories > Baby & Toddler Belts
    ]]>
    </g:google_product_category>
    <g:product_type>
    Clothing > Hoodies > Green Hoodies > New Green Hoodies
    </g:product_type>
    <link>https://wppfmdebugshop.test/product/hoodie/</link>
    <g:image_link>
    https://wppfmdebugshop.test/wp-content/uploads/2018/03/hoodie-2.jpg
    </g:image_link>
    <g:price>2.938,30 USD</g:price>
    <g:condition>new</g:condition>
    <g:availability>in stock</g:availability>
    <g:adult>no</g:adult>
    <g:multipack>no</g:multipack>
    <g:identifier_exists>yes</g:identifier_exists>
    <g:is_bundle>2</g:is_bundle>
    <g:shipping>
    <g:country>US</g:country>
    <g:region>MO</g:region>
    <g:service>Over land</g:service>
    <g:price>6.49 USD</g:price>
    </g:shipping>
    <g:shipping>
    <g:country>US</g:country>
    <g:region>MA</g:region>
    <g:service>Express</g:service>
    <g:price>15.99 USD</g:price>
    </g:shipping>
    </item>

    Could you send me a few other samples of category names you’re using?

    Plugin Contributor Michel Jongbloed

    (@michel-jongbloed)

    Hi @marekbo12,

    I would like to test some different words Polish category strings. Could you send me some category names you’re using?

    Thread Starter marekbo12

    (@marekbo12)

    Hey, I’m sorry to be so late writing back.
    It’s hard for me to say now because I’m using another plugin. However, I remember that there was also a problem with these categories in displaying breadcrumb on the product card – the last categories did not display.

    Plugin Contributor Michel Jongbloed

    (@michel-jongbloed)

    OK @marekbo12,

    In that case, if you don’t mind I will close your topic. Should you wish to use our plugin again don’t hesitate to reopen it again so we can follow on on it.

    Have a nice day.

    Thread Starter marekbo12

    (@marekbo12)

    You can close the subject. Don’t take it personally, but I was under a customer pressure and had to look for an alternative solution.
    We can come back to this one day if there are similar problems.

    Plugin Contributor Michel Jongbloed

    (@michel-jongbloed)

    No problem @marekbo12. I can understand that sometimes its better to look for other solutions.

    Thread Starter marekbo12

    (@marekbo12)

    OK, thank you

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Product Category String does not generate all categories’ is closed to new replies.