% move the percentage sign to the left. Set as 50% sale

This topic has 10 replies, 3 voices, and was last updated 7 months ago ago by Jack Richardson

  • Avatar: Recep
    Recep
    Participant
    April 30, 2025 at 13:16

    hello,

    In our country, the percentage sign must be used at the beginning of the word as a discount rate! How can we set this?

    It should be like “%50 Sale”. sale %50 is an incorrect use.

    It should be like this on both the store screen and the single product page.

    Regards,

    Recep

    Please, contact administrator
    for this information.
    9 Answers
    Avatar: Alex Carter
    Alex Carter
    Support staff
    April 30, 2025 at 13:39

    Hello,

    Thank you for reaching out to us.

    Could you please provide temporary wp-admin and FTP access? We will check what can be done to help you.
    To grant WP-Admin access, please proceed to create a new user account with an administrator role through your WordPress Dashboard. Once the account is established, you may securely transmit the username and password to us via the Private Content section designated for this purpose.

    For FTP access, we require the following details: FTP host, FTP username, FTP password, FTP port, and FTP encryption type. If you need assistance in creating these credentials, please reach out to your hosting provider who will guide you through the process.

    Warm Regards,
    The 8Theme Team

    Avatar: Recep
    Recep
    Participant
    May 13, 2025 at 15:11

    Hello,

    I apologize for the late response due to special reasons. What is the access information needed for? Can we do this with your instructions? (you made unauthorized changes when we gave you access before!)

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    May 13, 2025 at 15:50

    Dear @Recep,

    We hope this message finds you well.

    If you have already installed the Loco Translate plugin (or if you didn’t then you can install it), you can access the translation files for the XStore theme. Within these files, please search for the following string: “{sales_text} %s”. You may then modify it to suit your preferred structure, for example: “%s {sales_text}”.

    Please ensure that the special variables within the strings remain unchanged, as they will be dynamically replaced with calculated values based on the product’s sale price.

    Should you have any further questions or require assistance, feel free to reach out.

    Best regards,
    Jack Richardson
    The 8Theme Team

    Avatar: Recep
    Recep
    Participant
    May 14, 2025 at 09:14

    hi Jack

    I did this but there was no change! The cache was cleared.

    Do you have another solution?

    Files is visible for topic creator and
    support staff only.
    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    May 14, 2025 at 10:29

    Dear @Recep,

    We hope this message finds you well.

    We have reviewed your shop page, and the sale text appears to be displaying correctly, as shown in the following screenshot: https://prnt.sc/-tzCHNP-vY25.

    Could you kindly check the view from your side once again? We also recommend verifying the product sale badges using a different device or browser, if possible.

    Please let us know your findings.

    Best regards,
    Jack Richardson
    The 8Theme Team

    Avatar: Recep
    Recep
    Participant
    May 14, 2025 at 10:33

    hi,

    it still looks wrong in the image you sent. % should be before the number. You specified it as “%s {sales_text}” in your message above.

    So the correct version should be “%30 DISCOUNT”.

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    May 15, 2025 at 07:19

    Dear @Recep,

    If you are using a child theme, kindly add the following code to the functions.php file of your child theme:

    function etheme_sale_label_percentage_text( $product_object, $sale_text, $is_single_product = false ) {
    		$element_options = array();
    		if ( ! $product_object->is_on_sale() ) {
    			return $sale_text;
    		}
    		$element_options['sale_label_text'] = $sale_text;
    		$sale_variables = $is_single_product || etheme_get_option( 'sale_percentage_variable', 0 );
    		$product_type = $product_object->get_type();
    		if ( $product_type == 'variable' ) {
    			if ( $sale_variables ) {
    				$element_options['variation_sale_prices'] = array();
    				foreach ( $product_object->get_available_variations() as $key ) {
    					if ( $key['display_regular_price'] == $key['display_price'] ) {
    						continue;
    					}
    					$element_options['variation_sale_prices'][] = (float) round( ( ( $key['display_regular_price'] - $key['display_price'] ) / $key['display_regular_price'] ) * 100 );
    				}
    				if ( count($element_options['variation_sale_prices']) )
    				    $element_options['sale_label_text'] = sprintf( esc_html__( 'Up to %s', 'xstore' ), '%' . max( $element_options['variation_sale_prices'] ) );
    			}
    		} elseif ( $product_type == 'grouped' ) {
    			if ( $sale_variables ) {
    				$element_options['grouped_sale_prices'] = array();
    				foreach ( $product_object->get_children() as $key ) {
    					$_product = wc_get_product( $key );
    					if ( $_product->get_type() == 'variable' && $_product->is_on_sale() ) {
    						foreach ( $_product->get_available_variations() as $key ) {
    							if ( $key['display_regular_price'] == $key['display_price'] ) {
    								continue;
    							}
    							$element_options['grouped_sale_prices'][] = (float) round( ( ( $key['display_regular_price'] - $key['display_price'] ) / $key['display_regular_price'] ) * 100 );
    						}
    					} else {
    						if ( $_product->is_on_sale() ) {
    							$regular_price = (float) $_product->get_regular_price();
    							$sale_price    = (float) $_product->get_sale_price();
    							if ( $regular_price == $sale_price ) {
    								continue;
    							}
    							$element_options['grouped_sale_prices'][] = (float) round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
    						}
    					}
    				}
    				$element_options['sale_label_text'] = sprintf( esc_html__( 'Up to %s', 'xstore' ), '%' . max( $element_options['grouped_sale_prices'] ) );
    			}
    		} else {
    			if ( apply_filters( 'etheme_sale_label_percentage', etheme_get_option( 'sale_percentage', 0 ) ) ){
    				if ( $product_type == 'bundle') {
    					$element_options['regular_price']   = (float) $product_object->min_raw_regular_price;
    					$element_options['sale_price']   = (float) $product_object->min_raw_price;
    				}
    				else {
    					$element_options['regular_price'] = (float) $product_object->get_regular_price();
    					$element_options['sale_price']    = (float) $product_object->get_sale_price();
    				}
    				if ( $element_options['regular_price'] && $element_options['sale_price'] ) {
    
    					$element_options['sale_label_text'] = sprintf( str_replace('{sales_text}', $element_options['sale_label_text'], __( '{sales_text} %s', 'xstore' )), '%' . round( ( ( $element_options['regular_price'] - $element_options['sale_price'] ) / $element_options['regular_price'] ) * 100 ) );
    				}
    			}
    		}
    		
    		if ( class_exists( 'WAD_Discount' ) ) {
    			$all_discounts = wad_get_active_discounts( true );
    			$product_id    = $product_object->get_id();
    			if ( in_array( $product_type, array( 'variation', 'variable' ) ) ) {
    				$product_id = $product_object->get_available_variations();
    			}
    			foreach ( $all_discounts as $discount_type => $discounts ) {
    				foreach ( $discounts as $discount_id ) {
    					$discount_obj = new WAD_Discount( $discount_id );
    					if ( $discount_obj->is_applicable( $product_id ) ) {
    						$settings                           = $discount_obj->settings;
    						$element_options['sale_label_text'] = sprintf( esc_html__( 'Sale %s', 'xstore' ), '%'.$settings['percentage-or-fixed-amount'] );
    					}
    				}
    			}
    		}
    		
    		return $element_options['sale_label_text'];
    	}

    Alternatively, if you are using a separate plugin to insert custom PHP snippets, please add the code there instead.

    If you prefer, you may also provide us with the correct FTP and WordPress admin access credentials, and we will be happy to implement the changes on your website for you.

    Best regards,
    The 8Theme Team

    Avatar: Recep
    Recep
    Participant
    May 16, 2025 at 08:39

    hello,

    we can add the code but will we develop a solution other than adding this code?

    Avatar: Jack Richardson
    Jack Richardson
    Support staff
    May 16, 2025 at 12:10

    Dear @Recep,

    We hope this message finds you well.

    The solution we have provided addresses the issue you raised regarding the position of the % symbol. As this is the first request we have received for such a feature, we believe the current solution is appropriate for your needs.

    Should we receive additional requests for a similar issue in the future, we will certainly consider implementing a separate option. However, at this time, since the request is unique to your case, we believe the proposed solution is suitable.

    Thank you for your understanding.

    Best regards,
    The 8Theme Team

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

You must be logged in to reply to this topic.Log in/Sign up

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