Skip to content

Add Sunshine Photo Cart integration#70

Closed
derekashauer wants to merge 2 commits into
ElliotSowersby:masterfrom
derekashauer:feature/sunshine-photo-cart-integration
Closed

Add Sunshine Photo Cart integration#70
derekashauer wants to merge 2 commits into
ElliotSowersby:masterfrom
derekashauer:feature/sunshine-photo-cart-integration

Conversation

@derekashauer
Copy link
Copy Markdown

@derekashauer derekashauer commented Jan 16, 2026

Summary

  • Adds Sunshine Photo Cart ecommerce integration for login, registration, password reset, and checkout forms
  • Handles AJAX-loaded modal forms with explicit Turnstile rendering
  • Handles AJAX-based checkout flow with dynamic widget rendering on step changes
  • Includes guest-only checkout option
  • Includes admin settings UI under the Ecommerce section

Implementation Details

  • Login, registration, and password reset forms load via AJAX into modals, requiring explicit turnstile.render() calls
  • Checkout uses multi-step AJAX flow - Turnstile renders when payment section loads
  • Tokens are single-use, so turnstile.reset() is called after form submissions for retry attempts
  • Listens for Sunshine-specific jQuery events (require_login, login, signup, sunshine_reload_checkout, sunshine_checkout_payment_change)

Test plan

Requires Sunshine Photo Cart 3.6

  • Enable Sunshine Photo Cart integration in Turnstile settings
  • Test login form in modal - verify Turnstile widget appears and validates
  • Test registration form in modal - verify Turnstile widget appears and validates
  • Test password reset form in modal - verify Turnstile widget appears and validates
  • Test checkout flow - verify Turnstile widget appears on payment step
  • Test failed validation - verify user can retry after fixing the issue
  • Test guest-only option - verify logged-in users bypass Turnstile when enabled

This adds integration support for Sunshine Photo Cart, a photo gallery
and e-commerce plugin for professional photographers.

Features:
- Login form protection
- Registration form protection
- Lost password form protection
- Checkout form protection (with guest-only option)

Technical details:
- Handles AJAX-loaded modal forms by pre-loading Turnstile API and
  using explicit rendering with turnstile.render()
- Uses is_sunshine() to only load scripts on Sunshine pages
- Tracks rendered widgets to prevent duplicates from multiple event handlers
- Listens for Sunshine custom jQuery events (require_login, login, signup)
- Clears widget tracking when modal closes for clean re-renders

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@derekashauer derekashauer force-pushed the feature/sunshine-photo-cart-integration branch from 740bad8 to 1b2e947 Compare April 7, 2026 16:03
…ion is also enabled

Skip the global WordPress authenticate and registration_errors Turnstile
checks when the request originates from a Sunshine Photo Cart form.
Turnstile tokens are single-use, so the Sunshine-level validation consumes
the token before the WordPress-level check runs, causing false failures.

Uses the existing cfturnstile_wp_login_checks and cfturnstile_wp_register_checks
filters, matching the pattern used by WooCommerce and EDD integrations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants