• Resolved ajasra

    (@ajasra)


    Hi,
    I would like to thank you for the amazing work you guys are doing.
    I am working on a project where i need to over ride this ->

    center_modal = function() {
    
                var window_w = $(window).width(),
                    window_h = $(window).height(),
                    width    = ( ( window_w - 60 ) > qv_wrapper_w ) ? qv_wrapper_w : ( window_w - 60 ),
                    height   = ( ( window_h - 120 ) > qv_wrapper_h ) ? qv_wrapper_h : ( window_h - 120 );
    
                qv_wrapper.css({
                    'left' : (( window_w/2 ) - ( width/2 )),
                    'top' : (( window_h/2 ) - ( height/2 )),
                    'width'     : width + 'px',
                    'height'    : height + 'px'
                });
            };

    of the frontend.js

    Its possible to do with your other plugins, can you please let me know how do i do it ?
    I tried to copy and rename the frontend.js to ‘quick-view.js’, ‘yith-quick-view.js’ and ‘yith-woocommerce-quick-view’.

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi here,

    yes you can but it’s not easy because the correct steps to do this is to…

    1. Copy the file frontend.js in your theme (it’s not important the folder and the filename) or (best solution) create a new plugin for this, in this case you can copy the file in this new plugin

    2. Edit the js file like you want

    3. Create a php code to dequeue the frontend.js file from plugin and enqueue you own file.

    It’s not hard to do, but you need a little bit of “confidence” with WordPress programming.

    Thread Starter ajasra

    (@ajasra)

    Thanks for your reply. I tried with the method you suggested and it works like a charm, though i didnt make a so called plugin out of it.

    For others needing to solve this issue, add this in the theme’s functions if a new plugin is not what want to make ->

    function custom_enqueue_js_scripts() {
        $path = get_template_directory_uri();
        // remove the yith quick view script to queue our hooked version
        wp_deregister_script('yith-wcqv-frontend');
        wp_enqueue_script('yith-wcqv-frontend', $path . '/woocommerce/yith-quick-view.js', '', '', true);
    }
    add_action('wp_enqueue_scripts', 'custom_enqueue_js_scripts');

    yith-quick-view.js‘ contains the custom script from yith-wcqv-frontend

    Plugin Author YITHEMES

    (@yithemes)

    Hi,
    yes, it’s ok. I tell to you to create a new plugin only to prevent to lost this code after theme update, only for this reason.
    Of course I means a little plugin only with the previous code inside, not with all plugin file, but this code in functions.php file it’s ok, the important is that you reached your goal.

    Thread Starter ajasra

    (@ajasra)

    Thanks again for the suggestion. Agreed to the fact that its better to put the code in a custom plugin instead of the functions. One suggestion, you might want to update the method of overriding the files like you guys do for the wishlist plugin.

    Cheers!

    Plugin Author YITHEMES

    (@yithemes)

    Hi there,

    What you mean for “update the method of overriding the files”?

    Thread Starter ajasra

    (@ajasra)

    By update, i meant copying the js file to the woocommerce theme and renaming it as the slug of the plugin and modify as required.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Override frontend.js’ is closed to new replies.