rebase from live enviornment

This commit is contained in:
Rachit Bhargava
2024-01-09 22:14:20 -05:00
parent ff0b49a046
commit 3a22fcaa4a
15968 changed files with 2344674 additions and 45234 deletions

View File

@@ -0,0 +1 @@
export const PAYMENT_METHOD_NAME = 'bacs';

View File

@@ -0,0 +1,53 @@
/**
* External dependencies
*/
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { getPaymentMethodData } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';
/**
* Internal dependencies
*/
import { PAYMENT_METHOD_NAME } from './constants';
const settings = getPaymentMethodData( 'bacs', {} );
const defaultLabel = __(
'Direct bank transfer',
'woocommerce'
);
const label = decodeEntities( settings?.title || '' ) || defaultLabel;
/**
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || '' );
};
/**
* Label component
*
* @param {*} props Props from payment API.
*/
const Label = ( props ) => {
const { PaymentMethodLabel } = props.components;
return <PaymentMethodLabel text={ label } />;
};
/**
* Bank transfer (BACS) payment method config object.
*/
const bankTransferPaymentMethod = {
name: PAYMENT_METHOD_NAME,
label: <Label />,
content: <Content />,
edit: <Content />,
canMakePayment: () => true,
ariaLabel: label,
supports: {
features: settings?.supports ?? [],
},
};
registerPaymentMethod( bankTransferPaymentMethod );

View File

@@ -0,0 +1 @@
export const PAYMENT_METHOD_NAME = 'cheque';

View File

@@ -0,0 +1,50 @@
/**
* External dependencies
*/
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { getPaymentMethodData } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';
/**
* Internal dependencies
*/
import { PAYMENT_METHOD_NAME } from './constants';
const settings = getPaymentMethodData( 'cheque', {} );
const defaultLabel = __( 'Check payment', 'woocommerce' );
const label = decodeEntities( settings?.title || '' ) || defaultLabel;
/**
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || '' );
};
/**
* Label component
*
* @param {*} props Props from payment API.
*/
const Label = ( props ) => {
const { PaymentMethodLabel } = props.components;
return <PaymentMethodLabel text={ label } />;
};
/**
* Cheque payment method config object.
*/
const offlineChequePaymentMethod = {
name: PAYMENT_METHOD_NAME,
label: <Label />,
content: <Content />,
edit: <Content />,
canMakePayment: () => true,
ariaLabel: label,
supports: {
features: settings?.supports ?? [],
},
};
registerPaymentMethod( offlineChequePaymentMethod );

View File

@@ -0,0 +1 @@
export const PAYMENT_METHOD_NAME = 'cod';

View File

@@ -0,0 +1,83 @@
/**
* External dependencies
*/
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { getPaymentMethodData } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';
/**
* Internal dependencies
*/
import { PAYMENT_METHOD_NAME } from './constants';
const settings = getPaymentMethodData( 'cod', {} );
const defaultLabel = __( 'Cash on delivery', 'woocommerce' );
const label = decodeEntities( settings?.title || '' ) || defaultLabel;
/**
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || '' );
};
/**
* Label component
*
* @param {*} props Props from payment API.
*/
const Label = ( props ) => {
const { PaymentMethodLabel } = props.components;
return <PaymentMethodLabel text={ label } />;
};
/**
* Determine whether COD is available for this cart/order.
*
* @param {Object} props Incoming props for the component.
* @param {boolean} props.cartNeedsShipping True if the cart contains any physical/shippable products.
* @param {boolean} props.selectedShippingMethods
*
* @return {boolean} True if COD payment method should be displayed as a payment option.
*/
const canMakePayment = ( { cartNeedsShipping, selectedShippingMethods } ) => {
if ( ! settings.enableForVirtual && ! cartNeedsShipping ) {
// Store doesn't allow COD for virtual orders AND
// order doesn't contain any shippable products.
return false;
}
if ( ! settings.enableForShippingMethods.length ) {
// Store does not limit COD to specific shipping methods.
return true;
}
// Look for a supported shipping method in the user's selected
// shipping methods. If one is found, then COD is allowed.
const selectedMethods = Object.values( selectedShippingMethods );
// supported shipping methods might be global (eg. "Any flat rate"), hence
// this is doing a `String.prototype.includes` match vs a `Array.prototype.includes` match.
return settings.enableForShippingMethods.some( ( shippingMethodId ) => {
return selectedMethods.some( ( selectedMethod ) => {
return selectedMethod.includes( shippingMethodId );
} );
} );
};
/**
* Cash on Delivery (COD) payment method config object.
*/
const cashOnDeliveryPaymentMethod = {
name: PAYMENT_METHOD_NAME,
label: <Label />,
content: <Content />,
edit: <Content />,
canMakePayment,
ariaLabel: label,
supports: {
features: settings?.supports ?? [],
},
};
registerPaymentMethod( cashOnDeliveryPaymentMethod );

View File

@@ -0,0 +1 @@
export const PAYMENT_METHOD_NAME = 'paypal';

View File

@@ -0,0 +1,49 @@
/**
* External dependencies
*/
import { registerPaymentMethod } from '@woocommerce/blocks-registry';
import { __ } from '@wordpress/i18n';
import { getPaymentMethodData, WC_ASSET_URL } from '@woocommerce/settings';
import { decodeEntities } from '@wordpress/html-entities';
/**
* Internal dependencies
*/
import { PAYMENT_METHOD_NAME } from './constants';
const settings = getPaymentMethodData( 'paypal', {} );
/**
* Content component
*/
const Content = () => {
return decodeEntities( settings.description || '' );
};
const paypalPaymentMethod = {
name: PAYMENT_METHOD_NAME,
label: (
<img
src={ `${ WC_ASSET_URL }/images/paypal.png` }
alt={ decodeEntities(
settings.title || __( 'PayPal', 'woocommerce' )
) }
/>
),
placeOrderButtonLabel: __(
'Proceed to PayPal',
'woocommerce'
),
content: <Content />,
edit: <Content />,
canMakePayment: () => true,
ariaLabel: decodeEntities(
settings?.title ||
__( 'Payment via PayPal', 'woocommerce' )
),
supports: {
features: settings.supports ?? [],
},
};
registerPaymentMethod( paypalPaymentMethod );