__('ERP Bridge', 'ai-eshop-optimizer'), 'description' => __('Two-way bridge between WooCommerce and your physical-store ERP. Stock, prices, customers, and orders flow live across both systems — no manual CSV exports, no nightly batch jobs, no out-of-sync inventory.', 'ai-eshop-optimizer'), 'bullets' => array( __('Live stock sync — sell on Woo, the shelf count drops in the ERP within seconds.', 'ai-eshop-optimizer'), __('Configurable hook contract — pick which entities + directions are bridged.', 'ai-eshop-optimizer'), __('Works against any MariaDB / MySQL ERP via the encrypted ERP Database connection.', 'ai-eshop-optimizer'), ), ); } public function render_subtab() { $this->render_template('erp-bridge.php', array( 'hooks' => $this->get_hook_contract(), )); } public function get_hook_contract() { return array( array( 'type' => 'filter', 'name' => 'aieo_dmm_export_orders_row', 'description' => __('Mutate an individual row just before it is written to the orders export CSV. Passed the $row value array (the fixed 31-column SoftOne row, positional) plus a context array: ["result" => the SQL row object whose properties are the column aliases, "order_id" => int].', 'ai-eshop-optimizer'), 'warning' => __('Mutate values in place — the SoftOne column set is fixed (the ERP import template depends on it), so do not add or remove columns.', 'ai-eshop-optimizer'), 'example' => "add_filter('aieo_dmm_export_orders_row', function(\$row, \$ctx){\n // \$ctx['order_id'] = order id; \$ctx['result'] = the SoftOne SQL row object.\n // \$row is the fixed 31-value SoftOne column array (do not add/remove columns).\n return \$row;\n}, 10, 2);", ), array( 'type' => 'action', 'name' => 'aieo_docscan_document_applied', 'description' => __('Fired when a scanned supplier document is fully applied — stock received, cost written, operator signed off. Receives $document_id and the apply summary. This is the moment a purchase becomes real, so it is the correct hook for pushing it onward to accounting; it fires inside the operator\'s own request and never from cron.', 'ai-eshop-optimizer'), 'warning' => __('A listener must swallow its own failures: throwing here would make a successful apply look failed.', 'ai-eshop-optimizer'), 'example' => "add_action('aieo_docscan_document_applied', function(\$document_id, \$summary){\n // \$summary = ['mode'=>…, 'lines_applied'=>…, 'stock_added'=>…]\n // Push to your own accounting system here. Catch everything.\n}, 10, 2);", ), array( 'type' => 'filter', 'name' => 'aieo_docscan_erp_drivers', 'description' => __('Register another accounting-system target for the invoice scanner\'s ERP export (Rooster One Pro). Receives an array of driver objects keyed by id; add one extending AIEO_Docscan_ERP_Driver and it gains a settings card, a Send button per applied document, the shared push ledger and the exactly-once guard without any further wiring. The canonical payable it is handed is the same one every other target receives.', 'ai-eshop-optimizer'), 'example' => "add_filter('aieo_docscan_erp_drivers', function(\$drivers){\n if (class_exists('AIEO_Docscan_ERP_Driver')) {\n \$drivers['my_erp'] = new My_ERP_Driver(); // extends AIEO_Docscan_ERP_Driver\n }\n return \$drivers;\n});", ), array( 'type' => 'action', 'name' => 'aieo_dmm_after_import_stock', 'description' => __('Fired after each product has its stock updated by the Stock Import module. Use for ERP callbacks.', 'ai-eshop-optimizer'), 'example' => "add_action('aieo_dmm_after_import_stock', function(\$product_id, \$stock, \$job_id){\n // push a mirror update back to the ERP…\n}, 10, 3);", ), array( 'type' => 'filter', 'name' => 'aieo_dmm_feed_item', 'description' => __('Mutate a single feed item just before it is serialised. Receives $row, $feed_slug, $feed_config.', 'ai-eshop-optimizer'), 'example' => "add_filter('aieo_dmm_feed_item', function(\$row, \$slug, \$feed){\n if (\$slug === 'skroutz') { \$row['g:custom_label_0'] = 'vip'; }\n return \$row;\n}, 10, 3);", ), array( 'type' => 'filter', 'name' => 'aieo_dmm_needs_taxonomy', 'description' => __('Override the default product-need taxonomy slug (default: pa_need).', 'ai-eshop-optimizer'), 'example' => "add_filter('aieo_dmm_needs_taxonomy', fn() => 'my_needs');", ), ); } }