Open andrewrowanwallee opened 2 years ago
@prestaforum any ideas?
php Copy code // Register the hook in your module's install function public function install() { return parent::install() && $this->registerHook('actionRefundShippingCosts'); }
// Implement the hook execution logic in your module public function hookActionRefundShippingCosts($params) { // Add your logic to handle the refund of shipping costs here }
php Copy code // Assuming $order and $shippingRefundAmount are defined Hook::exec('actionRefundShippingCosts', [ 'order' => $order, 'amount' => $shippingRefundAmount ]);
php Copy code $order->total_paid -= $shippingRefundAmount; $order->total_paid_tax_incl -= $shippingRefundAmount; $order->total_paid_tax_excl -= $shippingRefundAmount; // Adjust according to whether your shipping costs are taxed or not $order->update();
php Copy code $order_slip = new OrderSlip(); $order_slip->id_customer = (int)$order->id_customer; $order_slip->id_order = (int)$order->id_order; $order_slip->conversion_rate = 1; // Modify based on your needs $order_slip->total_shipping_cost = $shippingRefundAmount; $order_slip->add();
Test Thoroughly Since this is a customization outside the standard PrestaShop workflows, thoroughly test this feature across different scenarios to ensure stability and reliability.
Consider the Payment Gateway Consult with your payment gateway provider or documentation to handle the actual refund process correctly. This might require API calls or other integrations to ensure the refunded amount is processed back through the customer's original payment method.
We have a use case whereby a merchant wishes to be able to refund only the shipping costs, not any part of the item. We need to be able to register this refund in our payment module but the hookActionProductCancel doesn't fire if no product is being cancelled. Is there a way to hook into shipping costs refunds? Thanks