Skip to content
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

Conversation

rodrigoi
Copy link
Contributor

@rodrigoi rodrigoi commented Jun 6, 2018

Changes proposed in this Pull Request:

  • Adds a form to manage Simple Payment Buttons from the customizer interface.
- -
Add New my movie 1 mp4
Edit edit
Delete delete
Cosed Open
screen shot 2018-06-06 at 15 10 32 screen shot 2018-06-06 at 15 11 15

Testing instructions:

Pre-requisites:

  • apply this branch on a Jetpack site with an active Business Plan subscription and a Theme with at least one widget area
  • have at least one previously created Simple Payment Button
  • open the Customizer on your Jetpack Business Site
  • go to Widgets and select a Widget Area
  • click on Add Widget
  • search on the widget panel for Simple Payment
  • select the Simple Payment widget

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:

  • click on Add New
  • fill the form. Using an image is optional, but it should open the media library if clicked.

The widget preview on the customizer should clear out, and display the entered values as they are typed on the form.

  • click Save

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.

  • click Cancel

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:

  • Select the desired product from the drop down list
  • click on Edit Selected

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.

  • click Save

the form should close, preserving the changes on the customizer preview window and the selected item on the product drop down list.

  • click Cancel

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:

  • Select the desired product from the drop down list.
  • click on Edit Selected

The form should load the product properties, and the widget preview on the customizer should show the correct product.

  • click Delete

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.

@rodrigoi rodrigoi added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. Simple Payments DO NOT MERGE don't merge it! labels Jun 6, 2018
@rodrigoi rodrigoi added this to the 6.3 milestone Jun 6, 2018
@rodrigoi rodrigoi self-assigned this Jun 6, 2018
@rodrigoi rodrigoi requested a review from a team June 6, 2018 18:39
@rodrigoi rodrigoi requested a review from a team as a code owner June 6, 2018 18:39
@matticbot matticbot added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it DO NOT MERGE don't merge it! Simple Payments Touches WP.com Files labels Jun 6, 2018
@rodrigoi rodrigoi force-pushed the add/simple-payments-widget-create-new branch from 45fbe1e to b3478f5 Compare June 6, 2018 19:00
@matticbot matticbot added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it DO NOT MERGE don't merge it! Simple Payments Touches WP.com Files labels Jun 6, 2018
@@ -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(
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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' ) );
Copy link
Contributor

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() {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed

I wouldn't say poor choice, more like automatic writing.

@gwwar
Copy link
Contributor

gwwar commented Jun 6, 2018

have at least one previously created Simple Payment Button

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?

@gwwar
Copy link
Contributor

gwwar commented Jun 6, 2018

Some high level stuff, feel free to break out into additional issues if they're too large:

  • We'll want to get a flow out for someone starting from 0 Simple Payments
  • 🤔 We're missing validation on both the customizer client and API endpoints. I'm able to create completely empty simple payment buttons (without any info)
    screen shot 2018-06-06 at 1 13 59 pm
    screen shot 2018-06-06 at 1 13 13 pm
  • Let's get some design feedback on the editing/adding workflows. For example could we hide the dropdown + top action buttons when creating a new payment?
    screen shot 2018-06-06 at 1 15 25 pm
  • I'm guessing the edit flows still need someone to work on them? (Feel free to create an issue) Right now I can click the button, but no fields are populated.

@gwwar
Copy link
Contributor

gwwar commented Jun 6, 2018

For reference this is part of Automattic/wp-calypso#24617

@gwwar
Copy link
Contributor

gwwar commented Jun 12, 2018

The joys of branching, let's get this rebased when you have time. 😄

@rodrigoi rodrigoi force-pushed the add/simple-payments-widget-create-new branch from 0cf560f to d787932 Compare June 13, 2018 07:12
@rodrigoi rodrigoi changed the title Simple Payment Widget: create new Payment Button Simple Payment Widget: Manage Products from the Customizer Jun 13, 2018
@rodrigoi rodrigoi merged commit 89ab826 into feature/widgets/simple-payment-widget Jun 15, 2018
@rodrigoi rodrigoi deleted the add/simple-payments-widget-create-new branch June 15, 2018 21:02
oskosk pushed a commit that referenced this pull request Jun 26, 2018
* 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
@kraftbj kraftbj removed the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label Sep 29, 2021
@jeherve jeherve added the [Feature] Pay with PayPal aka Simple Payments label Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Pay with PayPal aka Simple Payments Touches WP.com Files [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants