• Resolved mehakjami

    (@mehakjami)


    I’m plugin dev, after going into documentation i’ve added compatibility of checkout blocks in my payment plugin but still error msg of incompatible appears. No error display and nothing in console and logs. I have checked every topic regarding and correct where lacking but still its doesn’t appear. Help !!

    const settings = window.wc.wcSettings.getSetting( 'hblpay_data', {} );
    const label = window.wp.htmlEntities.decodeEntities( settings.title ) || window.wp.i18n.__( 'Hblpay', 'hblpay' );
    const Content = (hblpay_data) => {
    	return window.wp.htmlEntities.decodeEntities( hblpay_data.description || '' );
    };
    const Block_Gateway = {
    
    	name: 'hblpay',
    	label: hblpay_label,
    	content: Object( window.wp.element.createElement )( Content, null ),
    	edit: Object( window.wp.element.createElement )( Content, null ),
    	canMakePayment: () => true,
    	placeOrderButtonLabel: window.wp.i18n.__( 'Continue', 'wc_hblpay' ),
    	ariaLabel: hblpay_label,
    	supports: {
    		features: settings.supports,
    	},
    };
    window.wc.wcBlocksRegistry.registerPaymentMethod( Block_Gateway );
    

    This is my checkout.js in includes/block

    • This topic was modified 10 months, 1 week ago by mehakjami.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @mehakjami,

    Thank you for reaching out. It seems like you’ve already taken several steps to ensure compatibility with the WooCommerce checkout blocks. However, since the error message of incompatibility still appears, let’s go through a few checks together:

    1. Compatibility Check: Ensure that your plugin is compatible with the latest versions of WordPress and WooCommerce. Since you’re using WooCommerce 8.1, please update the version to 8.8.3.
    2. Checkout Blocks Registration: The code snippet you’ve provided looks correct at first glance. However, it’s crucial to ensure that all dependencies are enqueued correctly and that the registerPaymentMethod function is being called at the right time. Could you confirm if you’re enqueuing the script where this function is called with the wc-checkout-blocks as a dependency?
    3. Error Logging: Even though you mentioned that there are no errors in the console or logs, it might be helpful to enable WP_DEBUG and WP_DEBUG_LOG in your wp-config.php file to ensure that all errors are being logged. Sometimes, errors might not be displayed directly in the console but are logged in the debug file.
    4. Documentation Review: I recommend revisiting the documentation on using the block-based checkout, which provides a comprehensive guide to ensuring compatibility. You can find this guide here.

    Please give it a try and let us know how it goes.

    Thread Starter mehakjami

    (@mehakjami)

    This is class-hblpay-checkout-block.php

    <?php
    use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
    final class WC_Hblpay_Blocks extends AbstractPaymentMethodType {
    
    	private $gateway;
    	protected $name = 'hblpay';// your payment gateway name
    
    	public function initialize() {
    		$this->settings = get_option( 'woocommerce_hblpay_settings', [] );
    		$this->gateway = new WC_HblPay_Gateway();
    	}
    
    	public function is_active() {
    //var_dump($this->get_setting( 'enabled' ));die;
    		return $this->get_setting( 'enabled' ) === "yes";
    	}
    
    	public function get_payment_method_script_handles() {
    
    		wp_register_script(
    			'wc-hblpay-blocks-integration',
                plugin_dir_url(__FILE__) . 'block/checkout.js',
    			[
    				'wc-blocks-registry',
    				'wc-settings',
    				'wp-element',
    				'wp-html-entities',
    				'wp-i18n',
    			],
    			false,
    			true
    		);
    
    		if( function_exists( 'wp_set_script_translations' ) ) {
    			wp_set_script_translations( 'wc-hblpay-blocks-integration');
    		}
    		return [ 'wc-hblpay-blocks-integration' ];
    	}
    
    	public function get_payment_method_data() {
    		return [
    
    			'title' => $this->gateway->title,
    			'description' => $this->gateway->description,
    		];
    	}}
    

    And this is plugin main file where block is added:

    
    add_action('before_woocommerce_init', 'declare_cart_checkout_blocks_compatibility');
    
    function declare_cart_checkout_blocks_compatibility() {
        // Check if the required class exists
        if (class_exists('\Automattic\WooCommerce\Utilities\FeaturesUtil')) {
            // Declare compatibility for 'cart_checkout_blocks'
            \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('cart_checkout_blocks', __FILE__, true);
        }
    }
    
    add_action( 'woocommerce_blocks_loaded', 'hblpay_register_order_approval_payment_method_type' );
    
    /**
     * Custom function to register a payment method type
    
     */
    function hblpay_register_order_approval_payment_method_type() {
        // Check if the required class exists
        if ( ! class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
            return;
        }
    
        // Include the custom Blocks Checkout class
    	require_once( 'includes/class-hblpay-checkout-block.php' );
    
       
        add_action(
            'woocommerce_blocks_payment_method_type_registration',
            function(  Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) {
                // Register an instance 
                $payment_method_registry->register( new WC_Hblpay_Blocks );
            }
        );
    	}

    i’m using wc 8.8.3 and checking debug.log but nothing.

    Plugin Support ckadenge (woo-hc)

    (@ckadenge)

    Hi there @mehakjami,

    Helping out with custom coding of this nature is outside the scope of support that our support staff can help out with here, although I would recommend the following:

    1. Running the exact question you’re asking, along with the code provided, through an AI platform like ChatGPT for recommendations/changes to your code;
    2. Joining our WooCommerce Slack community (it does have a developer channel where you can ask coding questions): https://woo.com/community-slack/

    Hope it helps!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Payment Plugin not appearing on checkout in wordpress 6.5 and woocommerce 8.1’ is closed to new replies.