Home Forums WoodMart support forum Functions.js file

Functions.js file

Viewing 22 posts - 1 through 22 (of 22 total)
  • Author
    Posts
  • #68986

    Stanley Black
    Participant

    Hello,

    Functions.js file not compiling in functions.min.js file.

    Functions.js is not usable. Only changes in functions.min.js take effects.

    Best regards

    #68989

    Artem Temos
    Keymaster

    Hi,

    Yes, it doesn’t compile it automatically. There is no JS uglify library built in our theme. If you want to compile it automatically you will need to install node.js, grunt or gulp and uglify library on your machine.

    Kind Regards

    #69158

    Stanley Black
    Participant

    Thanks for response.

    I want to dequeue functions.min.js in my child-theme/functions.php file and than to enqueue
    functions.min.js from child theme.
    But wp_dequeue_script( ” ); not take effect at all.

    Can you give me a little help how to achieve that?

    Kind regards

    #69163

    Stanley Black
    Participant

    Something like this.

    function something_scripts() {
    wp_dequeue_script( ‘woodmart-theme’ );
    wp_enqueue_script( ‘woodmart-theme’, get_stylesheet_directory_uri() . ‘/js/functions.min.js’ );
    }
    add_action( ‘wp_print_scripts’, ‘something_scripts’ );

    This dequeue function.min.js but engueue the same file not function.min.js from child theme.

    #69168

    Stanley Black
    Participant

    I now that this line is problem

    wp_enqueue_script( ‘woodmart-theme’, get_stylesheet_directory_uri() . ‘/js/functions.min.js’ );

    Why import file from parent theme, not from child theme(js/functions.min.js).

    Is it necessary to change name of script ‘woodmart-theme’?

    Kind regards

    #69170

    Artem Temos
    Keymaster

    Try to add the following PHP code snippet to the child theme functions.php file to do this

    function woodmart_child_enqueue_scripts() {
        wp_deregister_script( 'woodmart-theme' );
        wp_enqueue_script( 'woodmart-theme', get_stylesheet_directory_uri() . '/child.js' );
    }
    add_action( 'wp_enqueue_scripts', 'woodmart_child_enqueue_scripts', 1000000 );
    #69176

    Stanley Black
    Participant

    In view page source is right path

    <script type=’text/javascript’ src=’http://www.roda.local/wp-content/themes/woodmart-idc/functions.min.js?ver=4.9.6′></script&gt;

    but with no effect because

    ReferenceError: woodmart_settings is not defined[Learn More] functions.min.js:1:1198

    #69179

    Artem Temos
    Keymaster

    Did you use only our code? Please, send us your website link.

    #69251

    Stanley Black
    Participant

    I modified functions.min.js but when restore this file from fresh theme installation the same error show up.

    Uncaught ReferenceError: woodmart_settings is not defined
    at functions.min.js?ver=4.9.7:1
    at functions.min.js?ver=4.9.7:3
    at functions.min.js?ver=4.9.7:3

    #69261

    Artem Temos
    Keymaster

    Please, send us your FTP access so we can check what is wrong.

    #69337

    Stanley Black
    Participant

    Hello,

    thanks in advance!

    #69341

    Artem Temos
    Keymaster

    You need to add our settings array before that code also. So the full code will be

    function woodmart_child_enqueue_scripts() {
        $translations = array(
            'adding_to_cart' => esc_html__('Processing', 'woodmart'),
            'added_to_cart' => esc_html__('Product was successfully added to your cart.', 'woodmart'),
            'continue_shopping' => esc_html__('Continue shopping', 'woodmart'),
            'view_cart' => esc_html__('View Cart', 'woodmart'),
            'go_to_checkout' => esc_html__('Checkout', 'woodmart'),
            'loading' => esc_html__('Loading...', 'woodmart'),
            'countdown_days' => esc_html__('days', 'woodmart'),
            'countdown_hours' => esc_html__('hr', 'woodmart'),
            'countdown_mins' => esc_html__('min', 'woodmart'),
            'countdown_sec' => esc_html__('sc', 'woodmart'),
            'wishlist' => ( class_exists( 'YITH_WCWL' ) ) ? 'yes' : 'no',
            'cart_url' => ( woodmart_woocommerce_installed() ) ?  esc_url( wc_get_cart_url() ) : '',
            'ajaxurl' => admin_url('admin-ajax.php'),
            'add_to_cart_action' => ( woodmart_get_opt( 'add_to_cart_action' ) ) ? esc_js( woodmart_get_opt( 'add_to_cart_action' ) ) : 'widget',
            'added_popup' => ( woodmart_get_opt( 'added_to_cart_popup' ) ) ? 'yes' : 'no',
            'categories_toggle' => ( woodmart_get_opt( 'categories_toggle' ) ) ? 'yes' : 'no',
            'enable_popup' => ( woodmart_get_opt( 'promo_popup' ) ) ? 'yes' : 'no',
            'popup_delay' => ( woodmart_get_opt( 'promo_timeout' ) ) ? (int) woodmart_get_opt( 'promo_timeout' ) : 1000,
            'popup_event' => woodmart_get_opt( 'popup_event' ),
            'popup_scroll' => ( woodmart_get_opt( 'popup_scroll' ) ) ? (int) woodmart_get_opt( 'popup_scroll' ) : 1000,
            'popup_pages' => ( woodmart_get_opt( 'popup_pages' ) ) ? (int) woodmart_get_opt( 'popup_pages' ) : 0,
            'promo_popup_hide_mobile' => ( woodmart_get_opt( 'promo_popup_hide_mobile' ) ) ? 'yes' : 'no',
            'product_images_captions' => ( woodmart_get_opt( 'product_images_captions' ) ) ? 'yes' : 'no',
            'ajax_add_to_cart' => ( apply_filters( 'woodmart_ajax_add_to_cart', true ) ) ? woodmart_get_opt( 'single_ajax_add_to_cart' ) : false,
            'all_results' => esc_html__('View all results', 'woodmart'),
            'product_gallery' => woodmart_get_product_gallery_settings(),
            'zoom_enable' => ( woodmart_get_opt( 'image_action' ) == 'zoom') ? 'yes' : 'no',
            'ajax_scroll' => ( woodmart_get_opt( 'ajax_scroll' ) ) ? 'yes' : 'no',
            'ajax_scroll_class' => apply_filters( 'woodmart_ajax_scroll_class' , '.main-page-wrapper' ),
            'ajax_scroll_offset' => apply_filters( 'woodmart_ajax_scroll_offset' , 100 ),
            'infinit_scroll_offset' => apply_filters( 'woodmart_infinit_scroll_offset' , 300 ),
            'product_slider_auto_height' => ( woodmart_get_opt( 'product_slider_auto_height' ) ) ? 'yes' : 'no',
            'header_builder' => ( woodmart_get_opt( 'header_builder' ) ) ? 'yes' : 'no',
            'price_filter_action' => ( apply_filters( 'price_filter_action' , 'click' ) == 'submit' ) ? 'submit' : 'click',
            'product_slider_autoplay' => apply_filters( 'woodmart_product_slider_autoplay' , false ),
            'loading' => esc_html__( 'Loading...', 'woodmart' ),
            'close' => esc_html__( 'Close (Esc)', 'woodmart' ),
            'share_fb' => esc_html__( 'Share on Facebook', 'woodmart' ),
            'pin_it' => esc_html__( 'Pin it', 'woodmart' ),
            'tweet' => esc_html__( 'Tweet', 'woodmart' ),
            'download_image' => esc_html__( 'Download image', 'woodmart' ),
            'cookies_version' => ( woodmart_get_opt( 'cookies_version' ) ) ? (int)woodmart_get_opt( 'cookies_version' ) : 1,
            'header_banner_version' => ( woodmart_get_opt( 'header_banner_version' ) ) ? (int)woodmart_get_opt( 'header_banner_version' ) : 1,
            'promo_version' => ( woodmart_get_opt( 'promo_version' ) ) ? (int)woodmart_get_opt( 'promo_version' ) : 1,
            'header_banner_close_btn' => woodmart_get_opt( 'header_close_btn' ),
            'header_banner_enabled' => woodmart_get_opt( 'header_banner' ),
            'whb_header_clone' => woodmart_get_config( 'header-clone-structure' ),
            'pjax_timeout' => apply_filters( 'woodmart_pjax_timeout' , 5000 ),
            'split_nav_fix' => apply_filters( 'woodmart_split_nav_fix' , false ),
            'shop_filters_close' => woodmart_get_opt( 'shop_filters_close' ) ? 'yes' : 'no',
            'woo_installed' => woodmart_woocommerce_installed(),
            'base_hover_mobile_click' => woodmart_get_opt( 'base_hover_mobile_click' ) ? 'yes' : 'no',
            'centered_gallery_start' => apply_filters( 'woodmart_centered_gallery_start' , 1 ),
        );
        wp_deregister_script( 'woodmart-theme' );
        wp_enqueue_script( 'woodmart-theme', get_stylesheet_directory_uri() . '/js/functions.min.js' );
        wp_localize_script( 'woodmart-theme', 'woodmart_settings', $translations );
    }
    add_action( 'wp_enqueue_scripts', 'woodmart_child_enqueue_scripts', 1000000 );
    #69349

    Stanley Black
    Participant

    Thanks!!!

    it’s works but one problem left.

    Instagram slider not take effects.

    Kind regards

    #69354

    Artem Temos
    Keymaster

    What instagram slider problem do you mean?

    #69359

    Stanley Black
    Participant

    Take a look of my website, I remove code from functions.php.
    That look of instagram slider I want.

    It seems when your code is added in functions.php, instagram slider not receive custom style from style.css.

    #69362

    Artem Temos
    Keymaster

    Please, describe to us your problem in a bit more details. Attach some screenshots and provide us with a list of steps on how to reproduce it on your website.

    Thank you in advance.

    #69369

    Stanley Black
    Participant

    I customize instagram slider in my child theme(style.css).
    Import custom arrows, decrease images, padding between images…(screenshot1.png).

    When I added your code for deregister script and enqueue script, instagram slider not have custom styles from my child theme, everyting gone(custom arrows, decrease images, padding between images…).screenshot2.png.

    Kind regards

    Attachments:
    You must be logged in to view attached files.
    #69380

    Artem Temos
    Keymaster

    But we don’t know how did you add your styles. The code we gave is just for JS script loaded from child theme. Maybe you did something wrong but additional code customizations are out of our theme support scope.

    #70327

    Stanley Black
    Participant

    Hello,

    Maybe in function woodmart_child_enqueue_scripts() is not script for instagram slider and then instagram slider not have his classes.

    All this classes has gone, they are invisibile, !important does not make a difference.

    .instagram-with-spaces.instagram-slider .owl-item {
    padding-left: 25px;
    padding-right: 25px;
    }

    .instagram-pics.owl-carousel .owl-nav > div {
    transform: translateY(0);
    -webkit-transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: visible;
    }
    .owl-nav>div[class*=prev]:after, .wrap-loading-arrow>div[class*=prev]:after {
    content: url(“http://www.new.idc.rs/wp-content/uploads/2018/05/left-arrow.png&#8221;);
    margin-left: 52px;
    }

    .owl-nav>div[class*=next]:after, .wrap-loading-arrow>div[class*=next]:after {
    content: url(“http://www.new.idc.rs/wp-content/uploads/2018/05/right-arow.png&#8221;);
    margin-right: 50px;
    }

    Kind regards

    #70329

    Artem Temos
    Keymaster

    Hi,

    Instagram scripts are not overridden in the child theme and CSS classes are the same there.

    Regards

    #70333

    Stanley Black
    Participant

    Thanks for response.

    I can’t find why instagram slider can’t be modified in style.css when functions.js is call from child theme.

    I will use some third plugin for instagram slider.

    Best regards

    #70363

    Artem Temos
    Keymaster

    OK, contact us if you will have any extra questions.

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