Commit 860f92d
Aleksei Tikhomirov
Add filters with order_id for custom receipt generation
This PR adds two filters to allow developers to customize receipt generation:
1. `robokassa_receipt_pre` - Called at the start of createRobokassaReceipt().
Return non-null value to bypass default receipt creation.
2. `wc_robokassa_receipt` - Now passes $order_id as second argument.
Allows modifying the generated receipt with access to order data.
Both filters pass $order_id, enabling:
- Custom pricing calculations (discounts, dynamic prices)
- Integration with other plugins without core modifications
- Access to order data for receipt customization
Usage examples:
// Pre-filter: complete override
add_filter('robokassa_receipt_pre', function($receipt, $order_id) {
$order = wc_get_order($order_id);
// Custom receipt generation logic
return $receipt;
}, 10, 2);
// Post-filter: modify existing receipt
add_filter('wc_robokassa_receipt', function($receipt, $order_id) {
$order = wc_get_order($order_id);
// Modify receipt items, totals, etc.
return $receipt;
}, 10, 2);
Backward compatible: existing filters without order_id argument will continue to work.1 parent b5a966e commit 860f92d
1 file changed
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
618 | 618 | | |
619 | 619 | | |
620 | 620 | | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
621 | 636 | | |
622 | 637 | | |
623 | 638 | | |
| |||
722 | 737 | | |
723 | 738 | | |
724 | 739 | | |
725 | | - | |
| 740 | + | |
726 | 741 | | |
727 | 742 | | |
728 | 743 | | |
| |||
0 commit comments