Skip to content

Commit

Permalink
Add metabox to show payment details
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Oct 20, 2023
1 parent ab3e073 commit 4069e88
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Mollie\WooCommerce\Gateway;

use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule;
use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule;
Expand Down Expand Up @@ -39,6 +40,7 @@
use Mollie\WooCommerce\PaymentMethods\Constants;
use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface as Logger;
use WP_Post;

class GatewayModule implements ServiceModule, ExecutableModule
{
Expand Down Expand Up @@ -301,10 +303,35 @@ static function ($paymentContext) {
$order->save();
}
);

add_action('add_meta_boxes_woocommerce_page_wc-orders', [$this, 'addShopOrderMetabox'], 10);
return true;
}

/**
* @param Object $post
* @return void
*/
public function addShopOrderMetabox(object $post)
{
if (! $post instanceof \WC_Order) {
return;
}
$meta = $post->get_meta('_mollie_payment_instructions');
if (empty($meta)) {
return;
}
$screen = wc_get_container()->get(CustomOrdersTableController::class)->custom_orders_table_usage_is_enabled()
? wc_get_page_screen_id('shop-order')
: 'shop_order';
add_meta_box('mollie_order_details', __('Mollie Payment Details', 'mollie-payments-for-woocommerce'), static function () use ($meta) {
$allowedTags = ['strong' => []];
printf(
'<p style="border-bottom:solid 1px #eee;padding-bottom:13px;">%s</p>',
wp_kses($meta, $allowedTags)
);
}, $screen, 'side', 'high');
}

/**
* Disable Bank Transfer Gateway
*
Expand Down
6 changes: 6 additions & 0 deletions src/Gateway/MolliePaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,12 @@ public function displayInstructions(

if (!empty($instructions)) {
$instructions = wptexturize($instructions);
//save instructions in order meta
$order->update_meta_data(
'_mollie_payment_instructions',
$instructions
);
$order->save();

if ($plain_text) {
echo esc_html($instructions) . PHP_EOL;
Expand Down

0 comments on commit 4069e88

Please sign in to comment.