-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple Payment Widget: Manage Products from the Customizer #9699
Simple Payment Widget: Manage Products from the Customizer #9699
Conversation
45fbe1e
to
b3478f5
Compare
modules/widgets/simple-payments.php
Outdated
@@ -13,6 +13,33 @@ | |||
* Display a Simple Payment Button as a Widget. | |||
*/ | |||
class Jetpack_Simple_Payments_Widget extends WP_Widget { | |||
private static $currencie_symbols = array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here.
Also, how will we keep this in sync? Is this also hardcoded in the SP endpoint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so we're probably basing this off of https://github.com/Automattic/wp-calypso/blob/f2494ca3b040fb7f87f9f5b0e49975a237d27150/client/components/tinymce/plugins/simple-payments/dialog/form.jsx#L41-L67 ?
For a start let's also link back to https://developer.paypal.com/docs/integration/direct/rest/currency-codes/
I'd also be surprised if WordPress didn't already have a currency to symbol mapping someplace.
This may be easier to maintain as an endpoint, but we can leave that for a future update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For WordPress.com we have a static function on the store that provides currencies, but there's no similar class on Jetpack 🙁
Typo fixed and docs link added on 66c5e61.
@@ -28,29 +55,108 @@ function __construct() { | |||
) | |||
); | |||
|
|||
if ( is_customize_preview() ) { | |||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_styles_and_scripts' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 verified that these only load related assets in the customizer
/** | ||
* Return an associative array of default values. | ||
* | ||
* These values are used in new widgets. | ||
* | ||
* @return array Default values for the widget options. | ||
*/ | ||
public function defaults() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious about the change here. Was this originally a poor choice, and nothing actually needed access to this instance method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like we can open another issue to work on getting around this limitation. @rodrigoi would you like to write this one up, or should I? |
For reference this is part of Automattic/wp-calypso#24617 |
The joys of branching, let's get this rebased when you have time. 😄 |
0cf560f
to
d787932
Compare
* Widgets: Adds support for Simple Payment Buttons as Widgets * Simple Payments Widget: Add style overrides (#9580) Override the media query and ensure that Simple Payments widgets are always displayed as a single column. * Widgets: Only render the Simple Payments widget if its button exists (#9673) In the frontend, only show the widget if the Simple Payments shortcode is parsed successfully. In the customizer, show the widget regardless, so that it can be modified via the pencil icon. * Simple Payment Widget: Manage Products from the Customizer (#9699) * Customizer: Simple Payments Widget breaks when starting without products (#9809) * Widgets: Hide Simple Payments create and edit buttons in widgets.php (#9811) * Widgets: Record events for the Simple Payments widget (#9803) * Widgets: Add Plan Check to the Simple Payments Widget (#9824) * Customizer: keep Simple Payments Widget Customizer in sync between instances (#9814) * Customizer: improves price validation on the Simple Payments Widget Customizer * Customizer: improves the behaviour of the action buttons on the Simple Payments Widget Customizer
Changes proposed in this Pull Request:
Testing instructions:
Pre-requisites:
at this point, a widget with defaulting to the first SP button should be added to the customizer sidebar.
All actions are atomic and effectively add or modify the existing products. Making a change on a product on the customizer without publishing affects products published on posts and pages. But changes on which product is shown on the widget only persist after being Published by the user.
To create a new product, you'll need to:
The widget preview on the customizer should clear out, and display the entered values as they are typed on the form.
the form should close, and the new SP button should be added to the drop down list. The customizer preview should show the new SP button.
the form should clear and close, and the previously selected SP button should appear on the customizer preview.
To edit and existing product, you'll need to:
The form should load the product properties, and the widget preview on the customizer should show the correct product, and update the values as they are edited on the form.
the form should close, preserving the changes on the customizer preview window and the selected item on the product drop down list.
the form should clear and close, and the previously selected SP button should appear on the customizer preview.
To delete an existing product, you'll need to:
The form should load the product properties, and the widget preview on the customizer should show the correct product.
After confirming the action, the selected product should disappear from the product drop down list. The first product on the list should be selected, and the customizer preview should reflect this change.