Repository navigation
feat(woocommerce): add 17 trigger events and 34 Pro actions - #234
Open
RishadAlam wants to merge 30 commits into
Open
RishadAlam wants to merge 30 commits into
RishadAlam wants to merge 30 commits into
Conversation
Add the Pro events Order Paid, Order Note Added, Order Refunded, Product Viewed, Product Out of Stock, Product Low Stock, Product Back in Stock, Variation Out of Stock, Variation Back in Stock, Review Approved, Review Status Changed, Review Rating Updated, Review Deleted, Coupon Created, Coupon Updated, Coupon Moved to Trash and Coupon Restored from Trash (IDs 34 to 50). Bit Integrations Pro fires them. The field list for each event reuses the order, product, review and coupon fields, and adds the note, refund, viewer, variation stock, review status and previous coupon status fields the events send.
…grations Pro Add 34 Pro modules to the WooCommerce action: order notes and meta, update and delete customer, update product, stock, status and price, delete product, product variations, category/tag/brand/shipping class terms, attributes and attribute terms, cart actions, the abandoned cart email, coupons and product reviews. WooCommerceActionModules defines the field map of each module, and wc_refresh_fields returns it. RecordApiHelper checks the required fields, merges the selected options into the field data, fires one bit_integrations_woocommerce_<module> filter per module and logs the response. The existing modules keep their own path.
The new wc_refresh_options route returns products and product categories, tags, brands or shipping classes as value/label pairs for the option dropdowns. A taxonomy that is not registered, such as product_brand before WooCommerce 9.6, returns an empty list.
WooCommerce and EditWooCommerce never passed setSnackbar to WooCommerceIntegLayout, so the field and subscription product refresh buttons threw when they tried to show their message.
The module select lists the 34 Pro modules in groups, disabled with a (Pro) label when Bit Integrations Pro is not active. Each module can show option selects above the field map, for fixed choices such as status or discount type and for store lists that load on demand with a refresh button, and utility checkboxes below it. The values are saved as selects and utilities and reset when the module changes. Next checks that required options are chosen.
A required field without a value logged "note is required for woocommerce add_order_note". The error now uses the field label, for example "Note is required".
…eld map Required rows were added one by one to the top of the field map, so they showed in reverse order, Amount before Coupon Code. They are now added together in their defined order. The + button is hidden when a module has no optional field left to add, since the new row could not be filled. Also drop an explanatory comment from staticData.js.
The Date Modified field of the coupon events was labelled Website, and Refunded By sends a user ID, so it is now labelled Refunded By User Id like Viewer User Id. The field keys do not change, so saved flows keep their mapping.
The product payload set _low_stock_amount to 1 for every product. It now sends the threshold WooCommerce uses for the product: its own value, then the parent product, then the store setting. Product Low Stock is the event that needs it most.
Add Product ID, Product Name, Variation ID, Quantity and Cart Total to the fields of Product Removed from Cart, the same details Product Added to Cart sends. Bit Integrations Pro sends the values.
The product option lists loaded every product as a full WC_Product with all its meta. A light get_posts query with the meta and term caches off returns the IDs and titles the dropdown needs, and it also lists products of types other plugins add, such as subscriptions.
MultiSelect reads its selected labels only when its value changes, so a saved category, tag or product looked empty when its list loaded after the select mounted, and picking a new value dropped the saved ones. The select now mounts again once its list is loaded and shows Loading... until then.
The Pro modules carry is_pro: true and the module select uses checkIsPro, the same check FluentCart and the other integrations use.
For the Pro modules, Next now says which row is incomplete, for example "Map a value for Amount", instead of "Field Map can't be empty". It also catches a custom value left empty.
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
The field map of each Pro module now lives in staticData.js as moduleFields, like QuizMaker and FluentCart. Choosing a module builds its field map in the browser instead of calling wc_refresh_fields, so WooCommerceActionModules.php is removed and the Refresh fields button is hidden for these modules. RecordApiHelper hands every module except the five original ones to Bit Integrations Pro and checks required fields against the field definitions saved with the flow. The original modules keep their own path, and generateMappedFields is back to its main version.
The five original modules and the 34 Pro modules now come from one moduleGroups list in staticData.js. The module field is a MultiSelect grouped by Order, Customer, Product and the rest, labelled with checkIsPro and getProLabel like the other integrations. Saved flows keep their module values.
WooCommerceActions.jsx renders the utility checkboxes, the name the other integrations use, and the layout shows the Utilities heading only when the module has utilities.
…ptions WooCommerceModuleOptions now holds the options of all modules: the Change Order Status filter and order change selects and the Cancel Subscription product select, moved from the layout unchanged, next to the Pro module option selects. The filter and order change lists, and the field rows each choice creates, move to staticData.js.
…ons run RecordApiHelper returns and logs an error when WooCommerce is not active, before it hands an action to Bit Integrations Pro, so Pro no longer repeats the check in each action.
Build MultiSelect options from a list of { name, label, is_pro, group }
items. Pro items get the (Pro) label and are disabled when Bit
Integrations Pro is not active. Items with a group are grouped in the
order the groups first appear, and items without one stay plain options.
Without Pro, the free options and the groups that hold them come first.
Integrations can use it instead of mapping checkIsPro and getProLabel
themselves.
The modules list is a flat list again, with a group on each module, and the layout passes it to getProSelectOptions instead of building the grouped options itself. Without Pro, the free modules are listed first.
The helper builds the options of a whole module list, free and Pro, so it is named after the modules lists it takes.
The WooCommerce action settings step gets a minimum height of 500px, so the module list has room to open below the Module field.
The field map listed form fields without a group and no General Smart Codes, so WordPress values such as the current user could not be mapped. The module field maps are nested per module, which Flow does not scan, so the controller now resolves smart code values itself.
The 500px minimum height applied on every step, so the hidden settings step stayed on screen as a squeezed column beside the final step.
The custom value check negated formField before comparing it, so it was always false and an empty Custom row passed validation.
The required check read the form value under the formField key, which is 'custom' for custom values, so a mapped custom SKU failed with "_sku is required". Customer rows used the raw custom value without replacing field placeholders.
The execution log showed only the new ID, such as 10.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds 17 WooCommerce trigger events and 34 WooCommerce write actions. This plugin lists the new events and their fields, and hands each new action to Bit Integrations Pro through its own
bit_integrations_woocommerce_<module>filter. Bit Integrations Pro fires the events and runs the actions (companion PR: https://github.com/bit-apps-pro/bit-integrations-pro/pull/156).Motivation & Context
Bit Flows already supports these WooCommerce events and actions, and Bit Integrations did not. Testing every event and action in a real store also turned up a few older WooCommerce trigger bugs, fixed here.
Related Links: (if applicable)
Type of Change
Key Changes
Triggers
_low_stock_amountin the product triggers: it was hardcoded to1. It now sends the threshold WooCommerce uses for the product.Actions
RecordApiHelper::executeModuleAction: a WooCommerce-active check, a required-field check against the field definitions saved with the flow, the selected options merged into the field data, one filter per module in aswitch, and a log entry for every path. The five original modules keep their own path.wc_refresh_optionsroute for the option lists: products, categories, tags, brands and shipping classes. Products load through a lightget_postsquery (no meta or term cache), which also lists product types that other plugins add, such as subscriptions.Frontend
MultiSelectbuilt from onemoduleGroupslist (the 5 original and 34 Pro modules), labelled withcheckIsPro/getProLabellike QuizMaker. Without Pro, the Pro modules show "(Pro)" and are disabled. Saved flows keep their module values.staticData.js, like QuizMaker:moduleFields(each field map), the option selects and the utilities. The field map is built in the browser, so these modules need no field request.WooCommerceModuleOptionsto hold the options of every module (the Change Order Status filter and order change selects and the Cancel Subscription product select moved in unchanged), andWooCommerceActionsto hold the utility checkboxes. The change-status lists and the field rows each choice creates moved tostaticData.js.setSnackbarto the layout, so the refresh buttons threw.Testing
eslint --max-warnings=0, Prettier, php-cs-fixer and PHPCompatibilityWP (7.4) are clean on the changed files.Checklist
Changelog
New Triggers
WooCommerce: 17 new events added (Pro).
New Actions
WooCommerce: 34 new events added (Pro).
Improvements
WooCommerce: Product Removed from Cart now includes the removed product's ID, name, variation, quantity and the cart total (Pro).
Bug Fixes
WooCommerce: Product Status Changed and Restore Product never ran, and Product Removed from Cart ran the Product Added to Cart flows (Pro).
WooCommerce: The Low Stock Amount field always sent 1. It now sends the product's low stock threshold.
WooCommerce: The coupon Date Modified field was labelled "Website".
🤖 Generated with Claude Code