-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from TycheSoftwares/Fix-#237
Fix #237 fees not showing on block checkout
- Loading branch information
Showing
4 changed files
with
15 additions
and
81 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array('wc-blocks-checkout', 'wp-element', 'wp-i18n'), 'version' => '7b2d759ead81217562b8'); | ||
<?php return array('dependencies' => array(), 'version' => '809990fb9b3428ea2e63'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,14 @@ | ||
import metadata from './block.json'; | ||
import { ValidatedTextInput } from '@woocommerce/blocks-checkout'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { useEffect, useState, useCallback } from '@wordpress/element'; | ||
import { extensionCartUpdate } from '@woocommerce/blocks-checkout'; | ||
|
||
// Global import | ||
const { registerCheckoutBlock } = wc.blocksCheckout; | ||
|
||
const Block = ({ children, checkoutExtensionData }) => { | ||
const { setExtensionData } = checkoutExtensionData; | ||
|
||
useEffect( () => { | ||
|
||
wp.hooks.addAction( 'experimental__woocommerce_blocks-checkout-set-active-payment-method', 'checkout-block-example', function( payment_method ) { | ||
var update_cart = extensionCartUpdate( { | ||
namespace: 'checkout-fees-for-woocommerce', | ||
data: { | ||
payment_method: payment_method.value, | ||
}, | ||
}); | ||
const { PAYMENT_STORE_KEY } = window.wc.wcBlocksData; // "wc/store/payment" | ||
const { extensionCartUpdate } = window.wc.blocksCheckout; | ||
const { subscribe, select } = wp.data; | ||
let previouslyChosenPaymentMethod = ''; | ||
|
||
subscribe( function () { | ||
const chosenPaymentMethod = select( PAYMENT_STORE_KEY ).getActivePaymentMethod(); | ||
extensionCartUpdate( { | ||
namespace: 'checkout-fees-for-woocommerce', | ||
data: { | ||
payment_method: chosenPaymentMethod, | ||
}, | ||
} ); | ||
|
||
wp.hooks.addAction( 'experimental__woocommerce_blocks-checkout-set-selected-shipping-rate', 'checkout-block-example', function( shipping ) { | ||
var update_cart = extensionCartUpdate( { | ||
namespace: 'checkout-fees-for-woocommerce', | ||
data: { | ||
payment_method: shipping.storeCart.paymentMethods[0], | ||
}, | ||
}); | ||
} ); | ||
|
||
}, [] ); | ||
|
||
const onInputChange = useCallback( | ||
( value ) => { | ||
}, | ||
[ setGiftMessage. setExtensionData ] | ||
) | ||
} | ||
|
||
const options = { | ||
metadata, | ||
component: Block | ||
}; | ||
|
||
registerCheckoutBlock( options ); | ||
}, PAYMENT_STORE_KEY ); |