I'm trying to charge an amount of $2.50 on an order where the manual payment method "04 - ESPAÑA CONTRAREEMBOLSO" is chosen.
I would like to know the reason why, when checking out, the value of 2.50$ is not being added to the order, the code I developed for this case was as follows, I cannot understand whether it is a Shopify limitation or some Syntax error / logic to capture this action.
{% if payment_method == '04 - ESPAÑA CONTRAREEMBOLSO' %}
{% assign surcharge = 2.50 %}
{% assign order_total = cart.total_price | money %}
{% assign new_total = cart.total_price | plus: surcharge %}
{% assign new_total_formatted = new_total | money %}
<p><strong>Note:</strong> A surcharge of {{ surcharge | money }} has been added to your order total for the payment method "04 - ESPAÑA CONTRAREEMBOLSO".</p>
<p><strong>New Order Total:</strong> {{ new_total_formatted }}</p>
{% endif %}
I attempted to add a new line in the checkout process called 'Cash on delivery fee' by inserting the code into the theme.liquid file. However, it doesn't seem to be working as intended.
<!-- ##### Test ESPAÑA ##### -->
{% if payment_method == '04 - ESPAÑA CONTRAREEMBOLSO' %}
<script>
$(document).ready(function() {
var surcharge = 2.50;
var total = {{ checkout.total_price | money_without_currency }};
var newTotal = total + surcharge;
$('.payment-due__price').html('{{ "Cash on delivery fee" | t }}: ' + Shopify.formatMoney(newTotal, '{{ shop.currency }}'));
$('.payment-due__currency').hide(); });
</script>
{% endif %}
Thank you all for your contribution