mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Set placement
This commit is contained in:
parent
c1376f927c
commit
ee1e6538dc
4 changed files with 29 additions and 3 deletions
|
@ -34,6 +34,10 @@
|
|||
"flexRatio": {
|
||||
"type": "string",
|
||||
"default": "8x1"
|
||||
},
|
||||
"placement": {
|
||||
"type": "string",
|
||||
"default": "auto"
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
|
|
|
@ -5,7 +5,7 @@ import { PanelBody, SelectControl, Spinner } from '@wordpress/components';
|
|||
import { PayPalScriptProvider, PayPalMessages } from "@paypal/react-paypal-js";
|
||||
|
||||
export default function Edit( { attributes, clientId, setAttributes } ) {
|
||||
const { layout, logo, position, color, flexColor, flexRatio, id } = attributes;
|
||||
const { layout, logo, position, color, flexColor, flexRatio, placement, id } = attributes;
|
||||
const isFlex = layout === 'flex';
|
||||
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
|
@ -99,6 +99,21 @@ export default function Edit( { attributes, clientId, setAttributes } ) {
|
|||
value={flexRatio}
|
||||
onChange={(value) => setAttributes({flexRatio: value})}
|
||||
/>)}
|
||||
<SelectControl
|
||||
label={ __( 'Placement page', 'woocommerce-paypal-payments' ) }
|
||||
help={ __( 'Used for the analytics dashboard in the merchant account.', 'woocommerce-paypal-payments' ) }
|
||||
options={ [
|
||||
{ label: __( 'Detect automatically', 'woocommerce-paypal-payments' ), value: 'auto' },
|
||||
{ label: __( 'Cart', 'woocommerce-paypal-payments' ), value: 'cart' },
|
||||
{ label: __( 'Payment', 'woocommerce-paypal-payments' ), value: 'payment' },
|
||||
{ label: __( 'Product', 'woocommerce-paypal-payments' ), value: 'product' },
|
||||
{ label: __( 'Product list', 'woocommerce-paypal-payments' ), value: 'product-list' },
|
||||
{ label: __( 'Home', 'woocommerce-paypal-payments' ), value: 'home' },
|
||||
{ label: __( 'Category', 'woocommerce-paypal-payments' ), value: 'category' },
|
||||
] }
|
||||
value={ placement }
|
||||
onChange={ ( value ) => setAttributes( { placement: value } ) }
|
||||
/>
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
<div {...useBlockProps({className: ['ppcp-paylater-block-preview', 'ppcp-overlay-parent']})}>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useBlockProps } from '@wordpress/block-editor';
|
||||
|
||||
export default function save( { attributes } ) {
|
||||
const { layout, logo, position, color, flexColor, flexRatio, id } = attributes;
|
||||
const { layout, logo, position, color, flexColor, flexRatio, placement, id } = attributes;
|
||||
const paypalAttributes = layout === 'flex' ? {
|
||||
'data-pp-style-layout': 'flex',
|
||||
'data-pp-style-color': flexColor,
|
||||
|
@ -12,6 +12,9 @@ export default function save( { attributes } ) {
|
|||
'data-pp-style-logo-position': position,
|
||||
'data-pp-style-text-color': color,
|
||||
};
|
||||
if (placement && placement !== 'auto') {
|
||||
paypalAttributes['data-pp-placement'] = placement;
|
||||
}
|
||||
const props = {
|
||||
className: 'ppcp-paylater-message-block',
|
||||
id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue