{% sw_extends '@Storefront/storefront/page/account/order-history/order-item.html.twig' %}
{% block page_account_order_item_context_menu_content %}
	{{ parent() }}
	{% block vrpayment_page_account_order_item_context_menu_content %}
		{% if page.extensions.vrpaymentSettings and page.extensions.vrpaymentSettings.storefrontInvoiceDownloadEnabled %}
			{% set vrpaymentFormattedHandlerIdentifier = 'handler_vrpaymentpayment_vrpaymentpaymenthandler' %}
			{% set orderPaymentState = order.transactions.last.stateMachineState.technicalName %}
			{% set orderPaymentMethodFormattedHandlerIdentifier = order.transactions.last.paymentMethod.formattedHandlerIdentifier %}
			{% if (vrpaymentFormattedHandlerIdentifier == orderPaymentMethodFormattedHandlerIdentifier) and (orderPaymentState in ['paid', 'refunded']) %}
				<a class="order-table-header-context-menu-content-link"
				   href="{{ path('frontend.vrpayment.account.order.download.invoice.document', { 'orderId': order.id }) }}"
				   title="{{ "vrpayment.account.downloadInvoice"|trans|sw_sanitize }}">
					{{ "vrpayment.account.downloadInvoice"|trans|sw_sanitize }}
				</a>
			{% endif %}
		{% endif %}
	{% endblock %}
{% endblock %}