• Resolved toddwdavis

    (@toddwdavis)


    Can I make a feature request for additional filters?

    1. On the template method within the Payment_Meta_Box_Controller class, in order to allow third party templates to be used.

    2. On line 15 of the main woo-mp.php file, allow the use of this plugin on other pages other than is_admin().

    Also, looking forward to the PRO version!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author bfl

    (@bfl)

    1. That’s a good idea. I think I’ll add that in the next release. What kinds of things are you looking to add with this filter?
    2. This plugin is designed to be used on the Edit Order screen. It wouldn’t work on the visitor-facing side of the website. What are you trying to achieve here? Maybe I can think of an alternative solution.
    Thread Starter toddwdavis

    (@toddwdavis)

    I’m using it in the WC Lovers Marketplace Frontend Manager. Being able to filter the Stripe Client Headers would be great too. I can send you the filters I’ve already added for my personal use.

    /**
         * Generate request headers.
         *
         * @param  string $processed_method The uppercase HTTP method.
         * @param  Config $config           Request configuration.
         * @return array                    Associative array of headers.
         */
        private function generate_request_headers( $processed_method, $config ) {
            $headers = [];
    
            if ( $config->api_version ) {
                $headers['Stripe-Version'] = $config->api_version;
            }
    
            if ( $config->secret_key ) {
                $headers['Authorization'] = "Bearer $config->secret_key";
            }
    
            if ( $processed_method === 'POST' ) {
                $headers['Idempotency-Key'] = $config->idempotency_key ?: bin2hex( random_bytes( 16 ) );
            }
    
            $headers = $config->headers + $headers;
    
            return apply_filters( 'woo_mp_stripe_request_headers', $headers ) ;
        }
    /**
         * Output a template.
         *
         * @param  string $name The name of the template.
         * @return void
         */
        private function template( $name ) {
            $directories = array_merge(
                $this->gateway_template_directories,
                [ WOO_MP_PATH . '/templates' ],
                Woo_MP::is_pro() ? [ WOO_MP_PRO_PATH . '/templates' ] : []
            );
    
            foreach ( $directories as $directory ) {
                $path = apply_filters( 'woo_mp_payment_meta_box_template', "$directory/$name.php", $name ) ;
    
                if ( is_readable( $path ) ) {
                    require $path;
    
                    break;
                }
            }
        }

    //main plugin file
    if ( ( ! is_admin() && ( ! defined( ‘DOING_CRON’ ) || ! DOING_CRON ) ) || is_network_admin() || ! apply_filters( ‘woo_mp_force_load’, false ) ) {
    return;
    }

    Plugin Author bfl

    (@bfl)

    I’m going to look into this soon.

    Plugin Author bfl

    (@bfl)

    A filter for Stripe request headers is also a good idea.

    Regarding WCFM: Do you mean that you are providing Woo MP to third-party vendors, and you were able to get it working on the screen shown here?

    Thread Starter toddwdavis

    (@toddwdavis)

    Yes I got it working on that page, but I had to include some localized variables from WC and I also rewrote the JS files, and while I was in there I upgraded Stripe.JS to use V3 elements.

    Plugin Author bfl

    (@bfl)

    Wow, I’m impressed! I think I’ll add that filter, but it will have to come with a warning. I’m concerned about the security implications of using Woo MP like that, as I built it with the assumption that it would only be used by trusted employees with access to the WP Admin. I also assumed it would only be used in the WP Admin, so I can’t guarantee that it will function correctly elsewhere.

    You probably already know this, but I would recommend testing each update of Woo MP on a staging/test site, as your customizations likely rely on internal implementation details.

    Thread Starter toddwdavis

    (@toddwdavis)

    Thanks for the update and fair warning!

    Plugin Author bfl

    (@bfl)

    I’ve added all 3 filters and they will be released in the next update.

    Plugin Author bfl

    (@bfl)

    The new filters are available now in version 2.7.0.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Needed Filters’ is closed to new replies.