What it does
When WooCommerce is active and a customer completes an order containing a GeoDirectory pricing-package product, mam-geodirectory updates every listing the customer authors to use the new package, prorating the expiry date based on the unused balance of their previous subscription.
The integration runs only when the WooCommerce class is loaded; the plugin’s bootstrap conditionalises both the class instantiation and the filter registration on class_exists('WooCommerce').
Activation
- WooCommerce installed and active.
- At least one GeoDirectory pricing package with a
woocommerce_product_idmeta key linking it to a WooCommerce product. - The MAM order pipeline fires
mam_wc_successful_simple_product_orderon order completion (this is mam-main / mam-woocommerce-bridge contract).
What the integration does
mam_gd_woocommerce::mam_wc_successful_simple_product_order($empty, $order):
- Reads the user’s currently-active package from their listings — picks the first
gd_placelisting whosepackage_idis non-empty and whoseexpire_dateis in the future. - Reads every WooCommerce product ID associated with a GeoDirectory pricing package via
geodir_pricing_get_packages+geodir_pricing_get_meta(..., 'woocommerce_product_id'). - Walks the order’s items (
$mam_order_detailsglobal). For each item that is a package product:- Sets the global
$gd_listing_idto the order item’slist_id. - Updates the listing’s
post_authorto the buyer. - Looks up the GeoDirectory package ID via
get_package_id_from_product. - Calls
update_listing_package_data($new_package_id, $old_package_id, $old_expiry).
- Sets the global
- Returns the upstream pass-through value unchanged.
update_listing_package_data proates the new expiry:
months_remaining = months between now and old expiry
amount_pending = (old_package.amount / 12) * months_remaining
months_to_add = round(new_package.amount / max(amount_pending, 1))
new_expiry = today + months_to_add months
Every gd_place post owned by the buyer is then updated to use the new package_id and expire_date. (Other GD post types are not touched by this function.)
Order return value injection
mam_gd_woocommerce::mam_wc_menu_order_return_vals($result):
When the order processed by the loop above completed, the global $gd_listing_id is set. This filter (mam_wc_menu_order_return_vals) reads that global and injects order_id into the WooCommerce return-value payload. The mobile app uses that order_id to refresh the right listing.
Things to watch for
- All
gd_placelistings the user owns are updated. A user with five listings under a single package will have all five rebased on the new package on a single order. This is by design but worth knowing for support cases. - Only
gd_place. Custom GD post types are not currently updated. If your directory uses a different post type for paid listings, the integration is a no-op for it. - Proration math is rough. The annualisation step assumes packages are billed annually (
old.amount / 12). For packages with non-annual recurrence, the prorated balance will be off; the runtime does not consultrecurringortime_unithere. - Order item shape. The integration relies on
$mam_order_detailshavingitem_idandlist_idkeys. That global is populated upstream; if the upstream contract changes, this integration silently no-ops.
Steps to enable
- Install and activate WooCommerce.
- Build a WooCommerce simple product per pricing package.
- Set the package’s
woocommerce_product_idmeta to the product’s ID (typically via the GeoDir Pricing UI). - Test an upgrade: have a test user with a known package buy the upgrade product. Confirm:
- All their
gd_placelistings show the newpackage_id. - The expiry date is in the future and prorated against their previous subscription.
- The order’s
order_idmatches the listing ID in the WooCommerce return value (helpful for app-side post-purchase deep-linking).
- All their
Verification
This article was last verified against:
- Plugin:
mam-geodirectoryv2.1.5 - Plugin: WooCommerce
- Plugin: GeoDir Pricing Manager
- Source:
includes/mam_gd_woocommerce.php
Re-verify whenever the mam_wc_successful_simple_product_order filter contract changes, the $mam_order_details global shape changes, GeoDirectory’s geodir_pricing_* API changes, or the proration formula in update_listing_package_data is updated.
Related articles
- Plugin: mam-geodirectory
- Recipe: Pricing package fields
- Form and flow: Claim Listing
Metadata
| Field | Value |
|---|---|
| Article type | Plugin Overview |
| Plugin slug | mam-geodirectory |
| Applies to plugin version | 2.1.5+ |
| Category | Plugin Reference |
| Audience | WordPress admin |
| Last verified | 2026-05-01 |
