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

fix/30: Prevent Gift Card image from being forced upon a site #198

Merged
merged 8 commits into from
Sep 20, 2024

Conversation

Sidsector9
Copy link
Member

@Sidsector9 Sidsector9 commented Aug 12, 2024

All Submissions:

  • Does your code follow the WooCommerce Sniffs variant of WordPress coding standards?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Will this change require new documentation or changes to existing documentation?

Changes proposed in this Pull Request:

Earlier, we added the default git card placeholder image to the media library on init hook.
In this PR, we add to the media library when the Gift card product placeholder image setting is enabled and the settings are saved at /wp-admin/admin.php?page=wc-settings&tab=checkout&section=gift_cards_pay.

This PR also adds a provision to replace the default placeholder for gift card via the following UI:

Screenshot 2024-08-12 at 7 15 24 PM

Closes #30

Steps to test the changes in this Pull Request:

  1. Delete the gift card placeholder (the purple one shown above) from the media library.
  2. Create 2 gift card products. One with the product image set, and another without.
  3. Go to /wp-admin/admin.php?page=wc-settings&tab=checkout&section=gift_cards_pay and enable Gift card product placeholder image and save it.
  4. Observe that the gift card placeholder gets added to the media library.
  5. Observe that the gift card product created without the product image shows the purple image as the default placeholder.
  6. Repeat (3) but this time replace the default placeholder.
  7. Repeat (5) but this time observe the default placeholder is updated with whatever image you've set.
  8. Delete the current active placeholder from the media library.
  9. Observe that the setting Gift card product placeholder image automatically gets disabled.
  10. Observe that the default placeholder for the gift card product is set to the image provided by Woo Core.

Changelog entry

Fix - Prevent Gift Card image from being forced upon a site.

@Sidsector9 Sidsector9 self-assigned this Aug 12, 2024
@qasumitbagthariya
Copy link
Contributor

QA Update ✅


I have verified this PR in the fix/30 branch, issue has been fixed and is functioning as intended.

I tested the following on this branch:

  • Gift card product placeholder image
  • Gift card without image
  • Block cart and checkout
  • Shortcode cart
  • Order again

Testing Environment

  • WordPress: 6.6.1
  • Theme: Storefront 4.6.0
  • Theme: Twenty Twenty-Four 1.2
  • WooCommerce - 9.1.4
  • PHP: 8.0.30
  • Web Server: Nginx 1.20.2
  • Browser: Chrome
  • OS: macOS Ventura 13.3
  • Branch: smoke-testing
Screen.Recording.2024-08-15.at.6.28.07.PM.mov
Screen.Recording.2024-08-15.at.6.25.31.PM.mov

Steps to Test- As mentioned in the PR description.
Test Results - It is working as expected.
Functional Demo / Screencast -
Special Notes - Ready for code review (Woo)
Testing Document status:
Cases related to this Issue/PR are added to the Critical Flow Wiki pages:

  • Yes
  • Not Required/Applicable for this PR

@qasumitbagthariya qasumitbagthariya requested review from a team and diegocurbelo and removed request for a team August 15, 2024 13:07
Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

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

The changes look good, and It tests well.

We are using the hard-coded string woocommerce_gift_cards_pay_settings in several files, we should use the constant SQUARE_PAYMENT_SETTINGS_OPTION_NAME instead.

It's true that option names rarely change, but using constants makes navigating the code easier, and remove the risk of typos.

I'm guessing we are not using it because of the long class name, if that's the case we can move it to includes/Gateway/Gift_Card.php class (or create a new one with a more descriptive name) so it's prettier:

  • WC_REST_Square_Gift_Cards_Settings_Controller::SQUARE_PAYMENT_SETTINGS_OPTION_NAME

  • Gift_Card::SQUARE_PAYMENT_SETTINGS_OPTION_NAME

@Sidsector9
Copy link
Member Author

Makes sense @diegocurbelo 👍
I've made the changes in 358beec.

Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

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

Thank you @Sidsector9, the changes look good 🚢

@vikrampm1 vikrampm1 added this to the Future Release milestone Aug 21, 2024
@jeffpaul jeffpaul modified the milestones: Future Release, 4.9.0 Aug 26, 2024
@vikrampm1 vikrampm1 removed this from the 4.9.0 milestone Sep 20, 2024
@vikrampm1 vikrampm1 added this to the 4.8.1 milestone Sep 20, 2024
@vikrampm1 vikrampm1 marked this pull request as ready for review September 20, 2024 14:04
@vikrampm1 vikrampm1 merged commit a679cc2 into trunk Sep 20, 2024
6 checks passed
@vikrampm1 vikrampm1 deleted the fix/30 branch September 20, 2024 14:05
@vikrampm1 vikrampm1 mentioned this pull request Sep 20, 2024
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gift Card image forced upon a site
6 participants