!function(){"use strict";var r={};function t(r){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},t(r)}function e(r){var e=function(r,e){if("object"!=t(r)||!r)return r;var o=r[Symbol.toPrimitive];if(void 0!==o){var c=o.call(r,e||"default");if("object"!=t(c))return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==t(e)?e:e+""}function o(r,t,o){return(t=e(t))in r?Object.defineProperty(r,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[t]=o,r}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)};var c=window.blocksyCustomizerSync,n=window.ctEvents,i=r.n(n);function a(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),e.push.apply(e,o)}return e}function l(r){for(var t=1;t

No posts were found.

/** * External dependencies */ import { registerPaymentMethod } from '@woocommerce/blocks-registry'; import { __ } from '@wordpress/i18n'; import { getSetting } from '@woocommerce/settings'; import { decodeEntities } from '@wordpress/html-entities'; /** * Internal dependencies */ import { PAYMENT_METHOD_NAME } from './constants'; const settings = getSetting( 'cod_data', {} ); 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 ; }; /** * 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: