Bulk XStore Options for Products for a Brand

This topic has 11 replies, 2 voices, and was last updated 1 years, 7 months ago ago by Mehmet

  • Avatar: Mehmet
    Mehmet
    Participant
    May 10, 2023 at 16:44

    Hello,
    I have created Static Blocks with brand information and featured products of that brand to be displayed in the custom tab of the Single Product Pages.

    I would like to bulk add static info for products of different brands, can you please advice?

    10 Answers
    Avatar: Mehmet
    Mehmet
    Participant
    May 10, 2023 at 16:50

    I am thinking may be a function on functions.php to automatically display the content or a more hardcore sql but I am lost at both approaches.

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    May 11, 2023 at 08:42

    Hello, Mehmet,

    Thank you for choosing XStore as your WooCommerce WordPress theme.

    In order to answer your question, we need to know the following:
    – Are you using our Single Product Builder to build the product?
    – Will you be using multiple brands for the product?
    – Could you provide URL of your site and temporary wp-admin access?

    Kind Regards,
    8theme team

    Avatar: Mehmet
    Mehmet
    Participant
    May 11, 2023 at 13:07

    Hello again,

    Yes I am using Single Product Builder. No I am using single brands for now. In the future there may be bundle-kit products that may require multiple brand relation.
    I am attaching the requested info in the private content area.

    Please contact administrator
    for this information.
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    May 11, 2023 at 15:59

    Hello, Mehmet,

    Thank you for your response.

    Additional customization in files is outside the scope of our basic support.
    But we want to help you, please follow the next steps:
    1/ Install patch #9146862 as indicated in the screenshot below: https://prnt.sc/kjuoEKbZh7OB
    2/ Add the following code to wp-content/themes/xstore-child/functions.php:

    add_filter('etheme_single_product_custom_tab_01_content_filter','etheme_block_by_brand');
    
    function etheme_block_by_brand($content){
    	if ($content=='{{et_block_by_brand}}'){
    		$terms = wp_get_post_terms( get_the_ID(), 'brand' );
    
    		if ( ! is_wp_error( $terms ) && count( $terms ) > 0 ) {
    			if (isset($terms[0]->term_id)){
    				$args = array(
    					'post_type' => 'staticblocks',
    					'meta_query' => array(
    						array(
    							'key' => 'et_brand_id',
    							'value' => $terms[0]->term_id,
    							'compare' => '=',
    						)
    					)
    				);
    				$posts = get_posts( $args );
    				if (isset($posts[0]->ID)){
    					return etheme_static_block( $posts[0]->ID, false );
    				}
    			}
    		}
    	}
    	return $content;
    }

    3/ Go to Customizer -> WooCommerce (Shop) -> Tabs -> Custom Tab 01 Content and enter the code {{et_block_by_brand}} as indicated in the screenshot: https://prnt.sc/m0i2JFHd-8lY and save the changes.
    4/ Go to the static block editing and scroll down to the “Custom Fields” section.
    5/ Add a new custom field as indicated in the screenshot: https://gyazo.com/04ae5a72ac252664e99c34d846439a72 The “Name” field should always be et_brand_id and in the “Value” field, enter the brand ID. To find the brand ID, go to the brand editing window, details are in the screenshot: https://prnt.sc/SVx9wdkUGMQN

    Kind Regards,
    8theme team

    Avatar: Mehmet
    Mehmet
    Participant
    May 12, 2023 at 04:13

    Hello Rose,

    Holly molly! Thank you for the instructions. You guys really know how to keep your customers happy.

    I have applied your instructions, cleared the caches and everything a few times, but all I get {{et_block_by_brand}} instead of the static block content.

    I have even added control echos to the code to see if everything is working as they should but the
    if ($content=='{{et_block_by_brand}}’) ” control does seem to work.

    
    function etheme_block_by_brand($content){
    	echo "Check 1"; //Works
    	
    	if ($content=='{{et_block_by_brand}}'){
    		echo "Check 2"; //Does not work
    		
    		$terms = wp_get_post_terms( get_the_ID(), 'brand' );
    
    		if ( ! is_wp_error( $terms ) && count( $terms ) > 0 ) {
    			echo "Check 3"; //Does not work
    			
    			if (isset($terms[0]->term_id)){
    				echo "Check 3"; //Does not work
    				$args = array(
    					'post_type' => 'staticblocks',
    					'meta_query' => array(
    						array(
    							'key' => 'et_brand_id',
    							'value' => $terms[0]->term_id,
    							'compare' => '=',
    						)
    					)
    				);
    				$posts = get_posts( $args );
    				if (isset($posts[0]->ID)){
    					echo "Check 5"; //Does not work
    					return etheme_static_block( $posts[0]->ID, false );
    				}
    			}
    		}
    	}
    	return $content; //returns the argument
    }
    

    The function just returns the argument variable content which is {{et_block_by_brand}}

    I checked the instructions a few times. Am I missing something?

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    May 12, 2023 at 09:09

    Hello, Mehmet,

    Please provide temporary FTP access.

    To create FTP access, please contact your hosting provider for assistance.

    Kind Regards,
    8theme team

    Avatar: Mehmet
    Mehmet
    Participant
    May 12, 2023 at 15:20

    Hello Rose,

    I do not have FTP server set up on our Google Cloud Instance. The plugin file editor works on WordPress. I can get you or check out the content you wish to take a look at.

    Please let me know how we can proceed…

    Please contact administrator
    for this information.
    Avatar: Mehmet
    Mehmet
    Participant
    May 12, 2023 at 15:43

    It seems to be working as of now. Don’t know what happened for it to start working. Did you change anything from my last post?

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    May 12, 2023 at 15:51

    Hello, Mehmet,

    We have fixed this issue, the problem was that the value of the “Custom Tab 01 Content” field was saved with “nbsp” HTML symbols https://prnt.sc/czakSwiH4BN8 and therefore the data did not match when checked https://prnt.sc/czakSwiH4BN8

    It is better to save such values using text mode https://prnt.sc/qtntwwmXlsKx

    Additionally, products without any brand will show {{et_block_by_brand}}.

    Kind Regards,
    8theme team

    Avatar: Mehmet
    Mehmet
    Participant
    May 12, 2023 at 20:31

    Thank you Rose, you have been great. In fact, the whole support system has been excellent, right from the start.

    I will definitely be extending my support when my time is up.

  • Viewing 11 results - 1 through 11 (of 11 total)

The issue related to '‘Bulk XStore Options for Products for a Brand’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.