Home Forums WoodMart support forum Change Select Option text to Buy now as soon as user selects the variation

Change Select Option text to Buy now as soon as user selects the variation

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #421279

    siddharth
    Participant

    Dear Developers,

    We are having an hard time in enabling this option…We want to change “Select Option” in sticky add to cart to clickable “Buy now” or any custom text as soon as user selects the variation. Currently in woodmart whenever the user clicks on select option he has to separately click on add to cart or buy now button inside the product page instead of directly clicking via sticky add to cart…(screenshot attached)

    Is there’s any snippet available to do that in woodmart…Please help its should be recommended feature in woodmart.

    • This topic was modified 1 year, 5 months ago by siddharth.
    Attachments:
    You must be logged in to view attached files.
    #421494

    Luke Nielsen
    Keymaster

    Hello,

    You can change the “Select Option” text on any another through the Loco Translate plugin. Here is our documentation on how to use it:

    https://xtemos.com/docs-topic/translate-woodmart-theme-with-loco-translate/

    Thanks for your time and have a great day.

    Kind Regards

    #421750

    siddharth
    Participant

    I don’t need translation of text i want to change the text to buy now as soon as user selects the variation and that should be clickable according to the variation selected

    #421805

    Luke Nielsen
    Keymaster

    Hello,

    This plugin is not only for translation, it can help easily change any text and here is an example with the same button.

    https://monosnap.com/file/UgHiYP3OfpTx9PgPLCdPBCdA8cb5fW

    https://monosnap.com/file/zgO0F8lV54QiBO8Otlb3rimWdp6Kfb

    Please let me know if such a way doesn’t fit you.

    Kind Regards

    #421875

    siddharth
    Participant

    Can’t we achieve the same thing without plugin?

    • This reply was modified 1 year, 5 months ago by siddharth.
    #421907

    Luke Nielsen
    Keymaster

    Yep, paste the below code to the functions.php file in your child theme.

    
    use XTS\Modules\Quick_Buy\Main as Quick_Buy;
    
    if ( ! function_exists( 'woodmart_sticky_single_add_to_cart' ) ) {
    
    	function woodmart_sticky_single_add_to_cart() {
    		global $product;
    
    		if ( ! woodmart_woocommerce_installed() || ! is_product() || ! woodmart_get_opt( 'single_sticky_add_to_cart' ) ) {
    			return;
    		}
    
    		woodmart_enqueue_js_script( 'sticky-add-to-cart' );
    		woodmart_enqueue_inline_style( 'sticky-add-to-cart' );
    
    		if ( woodmart_get_opt( 'mobile_single_sticky_add_to_cart' ) ) {
    			woodmart_enqueue_inline_style( 'woo-mod-quantity-overlap' );
    		}
    
    		?>
    			<div class="wd-sticky-btn<?php echo woodmart_get_old_classes( ' woodmart-sticky-btn' ); ?>">
    				<div class="wd-sticky-btn-container container<?php echo woodmart_get_old_classes( ' woodmart-sticky-btn-container' ); ?>">
    					<div class="wd-sticky-btn-content<?php echo woodmart_get_old_classes( ' woodmart-sticky-btn-content' ); ?>">
    						<div class="wd-sticky-btn-thumbnail<?php echo woodmart_get_old_classes( ' woodmart-sticky-btn-thumbnail' ); ?>">
    							<?php echo woocommerce_get_product_thumbnail(); ?>
    						</div>
    						<div class="wd-sticky-btn-info<?php echo woodmart_get_old_classes( ' woodmart-sticky-btn-info' ); ?>">
    							<h4 class="wd-entities-title"><?php the_title(); ?></h4>
    							<?php echo wc_get_rating_html( $product->get_average_rating() ); ?>
    						</div>
    					</div>
    					<div class="wd-sticky-btn-cart<?php echo woodmart_get_old_classes( ' woodmart-sticky-btn-cart' ); ?>">
    						<span class="price"><?php echo wp_kses_post( $product->get_price_html() ); ?></span>
    						<?php if ( $product->is_type( 'simple' ) ) : ?>
    							<?php woocommerce_simple_add_to_cart(); ?>
    						<?php else : ?>
    							<a href="<?php echo esc_url( $product->add_to_cart_url() ); ?>" class="wd-sticky-add-to-cart button alt<?php echo woodmart_get_old_classes( ' woodmart-sticky-add-to-cart' ); ?>">
    								<?php echo true == $product->is_type( 'variable' ) ? esc_html__( 'Select options', 'woodmart' ) : $product->single_add_to_cart_text(); ?>
    							</a>
    							<?php Quick_Buy::get_instance()->output_quick_buy_button(); ?>
    						<?php endif; ?>
    
    						<?php do_action( 'woodmart_sticky_atc_actions' ); ?>
    					</div>
    
    				</div>
    			</div>
    		<?php
    	}
    	add_action( 'woodmart_before_wp_footer', 'woodmart_sticky_single_add_to_cart', 999 );
    }
    

    Do not forget to edit the “Select Options” field.

    https://monosnap.com/file/cHgpg4R0sMF0jTZEeA9wZ2d0tCcaCQ

    Kind Regards

    • This reply was modified 1 year, 5 months ago by Luke Nielsen.
    #422399

    siddharth
    Participant

    The above snippet is not working….after activating the above snippet..some website element(specially the one’s which created through elementor) disappeared and i have noticed that it had affected those elements which have animations enabled on page load….also the sticky add to cart disappears as well. So, please check

    • This reply was modified 1 year, 5 months ago by siddharth.
    #422715

    Luke Nielsen
    Keymaster

    Hello,

    Kindly accept our sincere apologies for the inconvenience.

    I have edited the above code and now it should work, please replace the old one with the above code and check the issue again.

    Thanks for your patience. Hopefully, you are doing well.

    Kind Regards

    #423973

    siddharth
    Participant

    Thank you so much for helping me till now….no need to apologize and you have provided a good support till now.

    That glitch gets fixed…except….when i click on variation the text doesn’t gets changed…the behavior remains same. I mean the sticky add to cart text changes on page load but i want to change it as soon as i choose variation and but the current situation is after adding above snippet that when i click on add to cart sticky button then it scrolls to variation section and when i select variation it the sticky add to cart text remains unclickable and doesn’t gets changed.

    • This reply was modified 1 year, 5 months ago by siddharth.
    #424272

    Luke Nielsen
    Keymaster

    Hello,

    May I request you make a video with the issue for a better understanding? Also please provide the access to the admin dashboard so we can check it on your side.

    I look forward to hearing from you.

    Kind Regards

    #426172

    siddharth
    Participant

    Ok…will provide…please download the video in attachments…in this after applying your code…the variation text changes to “Choose options” but its gets changed on page load and also its not clickable but i want to change the sticky text as soon as user select any variation. If i click on choose options it gets scrolled me to the variation part which should not happen if the variation is selected. It should scroll to the variation part only when no variation is selected.

    • This reply was modified 1 year, 4 months ago by siddharth.
    Attachments:
    You must be logged in to view attached files.
    #426387

    Luke Nielsen
    Keymaster

    Hello,

    Sorry to say but right now there is no option in Theme Settings available for that. It’s the default behavior of the “Select Option” button in the sticky navbar. It requires Customization and this is beyond our limitations and support policy scope. Hope you can understand our limitations.

    Kind Regards

Viewing 12 posts - 1 through 12 (of 12 total)