Forum Replies Created

Viewing 15 replies - 1 through 15 (of 31 total)
  • Thread Starter gamernamer

    (@gamernamer)

    Thanks for your detailed answer!

    Kinda strange because we are using the code for a year now and it worked perfectly but the problem was in our code.

    // Hide Google and Apple Pay if lumise or redirect button
    jQuery(function($) { 
      if ($(".lumise-customize-button").length > 0 || (".redirect-add-to-cart-button").length > 0 ){
         $('.wc-stripe-product-checkout-container').remove();
      };
    }); 

    We forgot to add the $ in the second if parameter. That fixed the bug.

    Thanks for your answer!

    Best
    Justus

    Thread Starter gamernamer

    (@gamernamer)

    Thanks a lot ??

    Thread Starter gamernamer

    (@gamernamer)

    Right now the only way I see is by disabling the cache by setting a gt-no-cache cookie…

    Thread Starter gamernamer

    (@gamernamer)

    @fahadmahmood

    That works for us ??
    Would be awesome if you can push it on the next update!

    Thanks ??

    Thread Starter gamernamer

    (@gamernamer)

    @fahadmahmood

    I just realized that it doesn’t work properly after all. I’ve looked in your ‘wc_os_reduce_order_stock’ function. I am not sure about this line

    $updated_stock = ($items_ids[$item_key]['qty_ordered']+$items_ids[$item_key]['qty_stock_status']);

    Here you are adding the ordered Item count to the (already) reduced Item count. Should it not be?
    $updated_stock = ($items_ids[$item_key]['qty_stock_status']);

    // After that everything works as expected on our side (or am I missing a reason for that?)

    Justus

    Thread Starter gamernamer

    (@gamernamer)

    Thanks a lot!

    Thread Starter gamernamer

    (@gamernamer)

    I’ve tried it as well on 4.6.3. Still the same Problem.

    I have also tested some of the old versions of your plugin and noticed:

    1. In version 4.5.9 the stock changed when you set the order from ‘proccessing’ to ‘Pending payment’ but not in the other direction.
    2. Since 4.6.0 nothing changed anymore

    If you need anything else, don’t hesitate to contact me.
    Thanks for your help!
    Justus

    Thread Starter gamernamer

    (@gamernamer)

    Hey Fahad, thanks for the fast reply!
    We are using the ‘Inclusive’ method. I’ve created a short video to demonstrate the flow.

    + We are using wordpress an a multisite environment
    + There are no errors in our debug log
    + Newest Plugin Version
    + WordPress 5.9.3

    Best,
    Justus

    Thread Starter gamernamer

    (@gamernamer)

    Alright, solved it with jquery ??

    Thread Starter gamernamer

    (@gamernamer)

    Hey,

    Thanks a lot! Did not noticed it ^^

    Best,
    Justus

    Thread Starter gamernamer

    (@gamernamer)

    Worked, thanks ??

    Thread Starter gamernamer

    (@gamernamer)

    Thanks a lot for that detailed explanation! Very interesting to hear!

    Sorry for not giving more details of our wordpress network structure. Didn’t thought about it :/

    It’s not a big deal to activate it individually for us. I will try it on Monday ??

    Thanks a lot,
    Justus

    • This reply was modified 3 years, 6 months ago by gamernamer.
    Thread Starter gamernamer

    (@gamernamer)

    Thanks a lot for the fast reply ??

    Thread Starter gamernamer

    (@gamernamer)

    Thanks for your reply!

    Works great now.

    __
    For other people:

    // Helper function to load a WooCommerce template or template part file from the
    // active theme or a plugin folder.
    function bb_load_wc_template_file( $template_name ) {
        // Check theme folder first - e.g. wp-content/themes/bb-theme/woocommerce.
        $file = get_stylesheet_directory() . '/woocommerce/' . $template_name;
        if ( @file_exists( $file ) ) {
            return $file;
        }
    
        // Now check plugin folder - e.g. wp-content/plugins/myplugin/woocommerce.
        $file = 'wp-content/plugins/myplugin' . '/assets/templates/woocommerce/' . $template_name;
        if ( @file_exists( $file ) ) {
            return $file;
        }
    }
    add_filter( 'woocommerce_template_loader_files', function( $templates, $template_name ){
        // Capture/cache the $template_name which is a file name like single-product.php
        wp_cache_set( 'bb_wc_main_template', $template_name ); // cache the template name
        return $templates;
    }, 10, 2 );
    
    add_filter( 'template_include', function( $template ){
        if ( $template_name = wp_cache_get( 'bb_wc_main_template' ) ) {
            wp_cache_delete( 'bb_wc_main_template' ); // delete the cache
            if ( $file = bb_load_wc_template_file( $template_name ) ) {
                return $file;
            }
        }
        return $template;
    }, 11 );
    add_filter( 'wc_get_template_part', function( $template, $slug, $name ){
        $file = bb_load_wc_template_file( "{$slug}-{$name}.php" );
        return $file ? $file : $template;
    }, 10, 3 );
    
    add_filter( 'woocommerce_locate_template', function( $template, $template_name ){
        $file = bb_load_wc_template_file( $template_name );
        return $file ? $file : $template;
    }, 10, 2 );
    
    add_filter( 'wc_get_template', function( $template, $template_name ){
        $file = bb_load_wc_template_file( $template_name );
        return $file ? $file : $template;
    }, 10, 2 );

    Files need to be located in plugins/myplugin/assets/templates/woocommerce/ without any subfolder, just the files.

    Best,
    Justus

    Thread Starter gamernamer

    (@gamernamer)

    @mrclayton

    That’s it! I’ve just added the code to woocommerce_locate_template but not to wc_get_template… Haha that was very stupid. I tried all day yesterday and today I managed it after 5 minutes…

    The Important thing is: You need to add the subfolder “cc-forms” for example into the defined WooCommerce Folder. Not just the file or the woo-stripe-payment directory!

    If someone also wants to do that, here is my final code:

    # Helper for Oxygen / Tempalte to Plugin #
    ##################################################### 
    // Helper function to load a WooCommerce template or template part file from the
    // active theme or a plugin folder.
    function bb_load_wc_template_file( $template_name ) {
        // Check theme folder first - e.g. wp-content/themes/bb-theme/woocommerce.
        $file = get_stylesheet_directory() . '/woocommerce/' . $template_name;
        if ( @file_exists( $file ) ) {
            return $file;
        }
    
        // Now check plugin folder - e.g. wp-content/plugins/myplugin/woocommerce.
        $file = 'wp-content/plugins/myplugin' . '/assets/templates/woocommerce/' . $template_name;
        if ( @file_exists( $file ) ) {
            return $file;
        }
    }
    
    add_filter( 'woocommerce_template_loader_files', function( $templates, $template_name ){
        // Capture/cache the $template_name which is a file name like single-product.php
        wp_cache_set( 'bb_wc_main_template', $template_name ); // cache the template name
        return $templates;
    }, 10, 2 );
    
    add_filter( 'template_include', function( $template ){
        if ( $template_name = wp_cache_get( 'bb_wc_main_template' ) ) {
            wp_cache_delete( 'bb_wc_main_template' ); // delete the cache
            if ( $file = bb_load_wc_template_file( $template_name ) ) {
                return $file;
            }
        }
        return $template;
    }, 11 );
    
    add_filter( 'wc_get_template_part', function( $template, $slug, $name ){
        $file = bb_load_wc_template_file( "{$slug}-{$name}.php" );
        return $file ? $file : $template;
    }, 10, 3 );
    
    add_filter( 'wc_get_template', function( $template, $template_name ){
        $file = bb_load_wc_template_file( $template_name );
        return $file ? $file : $template;
    }, 10, 2 );
    

    First it will search in the template folder and after that it will search in /plugins/myplugin/assets/templates/woocommerce .

    Have a great day!
    Best,
    Justus

    • This reply was modified 4 years, 4 months ago by gamernamer.
Viewing 15 replies - 1 through 15 (of 31 total)