Skip to content

Fix featured listing order completion emails - #2966

Open
Arafat-plugins wants to merge 1 commit into
sovware:developmentfrom
Arafat-plugins:fix/featured-listing-admin-email-notification
Open

Fix featured listing order completion emails#2966
Arafat-plugins wants to merge 1 commit into
sovware:developmentfrom
Arafat-plugins:fix/featured-listing-admin-email-notification

Conversation

@Arafat-plugins

Copy link
Copy Markdown
Contributor

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Security fix
  • Improvement
  • New Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Text changes
  • Other... Please describe:

Description

How to reproduce the issue or how to test the changes

This fixes Directorist featured listing order completion emails not being sent for orders stored in the new Directorist orders table.

When a user purchases a featured listing, the order is created with ref_type=featured_listing in wp_directorist_orders. Marking that order as paid correctly publishes/features the listing, but the legacy atbdp_order_completed email hook was not fired for this new featured listing order path. As a result, the existing owner/admin completed-order emails were not sent, so the site admin did not receive the payment notification.

This change fires the existing atbdp_order_completed action when a featured listing order changes from a non-paid status to paid, reusing Directorist's native completed-order email flow. It also updates the email order-summary renderer so new table orders can render valid item, price, and total details in the email body.

  1. Enable monetization and Featured Listings in Directorist settings.
  2. Ensure Bank Transfer, or another manual/offline gateway, is active for checkout.
  3. Create/submit a listing as a user and proceed through the Featured Listing checkout.
  4. Complete the checkout with Bank Transfer, then mark the created featured listing order as paid.
  5. Before this fix, the listing becomes featured/published but no admin completed-order email is sent.
  6. After this fix, the existing completed-order email flow sends:
    • the owner completed-order email
    • the admin payment notification email
  7. Mark/save the already-paid order again and confirm duplicate completed-order emails are not sent.
  8. Confirm the email order details include the featured listing item, price, and total.

Any linked issues

Support ticket: https://team.sovware.com/support/directorist/3206

Screenshot

Checklist

@Arafat-plugins
Arafat-plugins force-pushed the fix/featured-listing-admin-email-notification branch from df90e6f to 4e4d870 Compare August 16, 2026 05:53
@RabbiIslamRony

Copy link
Copy Markdown
Member

Local review findings

I reproduced the reported issue locally against the exact PR base and then tested this PR head.

The core fix works:

  • On the base commit, changing a featured-listing order from pending to paid published/featured the listing, but atbdp_order_completed fired 0 times and no completed-order emails were generated.
  • On this PR, the hook fired once and both owner and admin emails were generated.
  • Saving the already-paid order again did not generate duplicate emails.
  • The rendered email contained the Featured item, price, currency, and total.

Before merge, please address these findings:

  1. Legacy and new-table order IDs are ambiguous

    ATBDP_Order::get_order_details() treats every numeric $order_id as a new-table primary ID first. Legacy emails pass a WordPress atbdp_orders post ID, while migrated orders store that value in legacy_id and receive a different auto-incremented id. When those numeric IDs collide, a legacy customer can receive details from an unrelated new-table order.

    Please pass an explicit new-order context/DTO into the email renderer or provide a separate new-table renderer instead of inferring the storage source from the numeric ID.

  2. The displayed currency symbol ignores the order currency

    $order_currency is used in the heading, but $symbol is calculated from the current global site currency. With a EUR order on a USD-configured site, the local output was:

    Price [EUR] $29.99 and Total amount [EUR] $29.99

    The symbol should be derived from $order_currency.

  3. The admin email links to the legacy Order History screen

    The generated email points to:

    wp-admin/edit.php?post_type=atbdp_orders

    New table orders are managed at:

    edit.php?post_type=at_biz_dir&page=directorist-orders#/edit/{order_id}

    The email should link to the matching new-order details screen.

  4. The empty-items fallback cannot obtain order_type or listing_title

    directorist_get_order_by_id() uses the raw get_by_id() query, which does not join the listing title or apply directorist_order_data. Therefore the fallback checks properties that are not present. A generic new-table order locally rendered only Order $29.99, without its listing title.

    Please load the joined/filtered order record, or explicitly query the required fields before constructing the fallback item.

Static verification also passed PHP syntax and git diff --check. Targeted PHPCS reported 0 errors. The current GitHub check is failing before PHPCS runs because the pull_request_target workflow refuses to check out fork code; that failure is workflow-policy related, not a PHPCS result.

@Arafat-plugins
Arafat-plugins force-pushed the fix/featured-listing-admin-email-notification branch from 4e4d870 to f98e541 Compare August 16, 2026 07:36
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