Home Forums WoodMart support forum Sticky product just on one page Reply To: Sticky product just on one page

#55504

Hello,

Please add this PHP snippet to the child theme.

function woodmart_body_class( $classes ) {

    $page_id = woodmart_page_ID();

    $site_width = woodmart_get_opt( 'site_width' );
    $product_design = woodmart_product_design();
    $product_sticky = woodmart_product_sticky();

    $ajax_shop = woodmart_get_opt( 'ajax_shop' );
    $ajax_search = woodmart_get_opt( 'search_ajax' );
    $hide_sidebar_mobile = woodmart_get_opt( 'shop_hide_sidebar' );
    $hide_sidebar_tablet = woodmart_get_opt( 'shop_hide_sidebar_tablet' );
    $hide_sidebar_desktop = woodmart_get_opt( 'shop_hide_sidebar_desktop' );
    $catalog_mode = woodmart_get_opt( 'catalog_mode' );
    $categories_toggle = woodmart_get_opt( 'categories_toggle' );
    $sticky_footer = woodmart_get_opt( 'sticky_footer' );
    $dark = woodmart_get_opt( 'dark_version' );
    $form_fields_style = ( woodmart_get_opt( 'form_fields_style' ) ) ? woodmart_get_opt( 'form_fields_style' ) : 'square';
    $form_border_width = woodmart_get_opt( 'form_border_width' );
    $menu_style = ( woodmart_get_opt( 'menu_style' ) ) ? woodmart_get_opt( 'menu_style' ) : 'default';
    $full_screen_menu = woodmart_get_opt( 'full_screen_menu' );

    $header_overlap = $header_sticky = $disable_sticky = false;

    $classes[] = 'wrapper-' . $site_width;
    // Form style settings
    $classes[] = 'form-style-' . $form_fields_style;
    $classes[] = 'form-border-width-' . $form_border_width;

    $classes[] = ( $full_screen_menu ) ? 'global-full-screen-menu' : '';

    if( is_singular( 'product' ) ) {
        $classes[] = 'woodmart-product-design-' . $product_design;
        if( $product_sticky || get_the_ID() == 51 ) {
            $classes[] = 'woodmart-product-sticky-on';
            woodmart_enqueue_script( 'woodmart-sticky-kit' );
        }
    }
    
    if ( woodmart_woocommerce_installed() && ( is_shop() || is_product_category() ) && ( $hide_sidebar_desktop && $sticky_footer ) ) {
        $classes[] = 'no-sticky-footer';
    }elseif( $sticky_footer ){
        $classes[] = 'sticky-footer-on';
    }
    
    $classes[] = ( $dark ) ? 'woodmart-dark' : 'woodmart-light';

    if( $catalog_mode ) {
        $classes[] = 'catalog-mode-on';
    } else {
        $classes[] = 'catalog-mode-off';
    }

    if( $categories_toggle ) {
        $classes[] = 'categories-accordion-on';
    } else {
        $classes[] = 'categories-accordion-off';
    }

    if( woodmart_is_blog_archive() ) {
        $classes[] = 'woodmart-archive-blog';
    } else if( woodmart_is_shop_archive() ) {
        $classes[] = 'woodmart-archive-shop';
    } else if( woodmart_is_portfolio_archive() ) {
        $classes[] = 'woodmart-archive-portfolio';
    }
    
    //Header banner
    if ( !woodmart_get_opt( 'header_close_btn' ) && woodmart_get_opt( 'header_banner' ) ) {
        $classes[] = 'header-banner-display';
    }
    if ( woodmart_get_opt( 'header_banner' ) ) {
        $classes[] = 'header-banner-enabled';
    }
    
    if( $ajax_shop ) {
        $classes[] = 'woodmart-ajax-shop-on';
    } else {
        $classes[] = 'woodmart-ajax-shop-off';
    }

    if( $ajax_search ) {
        $classes[] = 'woodmart-ajax-search-on';
    } else {
        $classes[] = 'woodmart-ajax-search-off';
    }

    if( $hide_sidebar_mobile ) {
        $classes[] = 'offcanvas-sidebar-mobile';
    }

    if( $hide_sidebar_tablet ) {
        $classes[] = 'offcanvas-sidebar-tablet';
    }

    if( $hide_sidebar_desktop ) {
        $classes[] = 'offcanvas-sidebar-desktop';
    }

    $classes = array_merge( $classes, woodmart_get_buttons_config_classes(), woodmart_get_header_body_classes() );

    return $classes;
}

add_filter('body_class', 'woodmart_body_class');

Then insert the ID of the product which you want to make sticky in this place of the code: http://prntscr.com/jc94jg

Best Regards