Add robokassa_receipt_pre filter for custom receipt generation#48
Open
tikhomirov wants to merge 10 commits intorobokassa:masterfrom
Open
Add robokassa_receipt_pre filter for custom receipt generation#48tikhomirov wants to merge 10 commits intorobokassa:masterfrom
tikhomirov wants to merge 10 commits intorobokassa:masterfrom
Conversation
Добавлен фильтр для итоговых данных чека
Исправлена совместимость виджета с PHP 8.1+
- Незначительные исправления
# Conflicts: # data/robokassa_DEBUG.txt # wp_robokassa.php
# Conflicts: # main_settings_credit.php # wp_robokassa.php
83d45ac to
860f92d
Compare
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.
860f92d to
19f08db
Compare
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.
Описание
Добавлен фильтр
robokassa_receipt_preв начало функции createRobokassaReceipt(),который позволяет разработчикам полностью переопределить логику формирования чека.
Зачем это нужно
Текущий фильтр
wc_robokassa_receiptвызывается в конце функции и не передаёт$order_id.Это делает невозможным:
Использование