Codigo para substituir url por VER BOLETO

De Tek-System Wiki
Ir para navegação Ir para pesquisar

Em minha conta> meus pedidos > pedido, o boleto aparece em forma de url e nao de link. Dessa maneira fica muito ruim para o cliente visualizar o boleto e baixá-lo, mesmo apesar de ser encaminhado um boleto para o seu email.

O código deve ser inserido na pagina html:

 Vendor/magento/module-sales/view/frontend/templates/order/info.phtml
 

O código a seguir deve ser inserido no final da pagina:

  function verificaSeUrlEhValida(urlBoleto){
        return (urlBoleto.indexOf("https://www.mercadopago.com/mlb/payments/ticket/helper?payment_id") != -1);
    }
    
    function validaQuantidadeDeLinhasNaTabelaItensPedido(){
        return document.getElementsByTagName("td").length > 9;
    }
    
    function validaQuantidadeDeLinhasNaTabelaItensEntrega(){
        return document.getElementsByTagName("td").length > 4;
    }
    
    function formataBoletoEmMeusPedidos(){
        if(validaQuantidadeDeLinhasNaTabelaItensPedido()){
            var urlBoleto_itens_pedido = document.getElementsByTagName("td")[9].innerHTML.trim();
            verificaSeUrlEhValida(urlBoleto_itens_pedido) ? document.getElementsByTagName("td")[9].innerHTML = "<a href='"+urlBoleto_itens_pedido+"' target=_blank'>Ver Boleto</a>" : "";
        }
    
        if(validaQuantidadeDeLinhasNaTabelaItensEntrega()){
            var urlBoleto_itens_entrega = document.getElementsByTagName("td")[4].innerHTML.trim();
            verificaSeUrlEhValida(urlBoleto_itens_entrega) ? document.getElementsByTagName("td")[4].innerHTML = "<a href='"+urlBoleto_itens_entrega+"' target=_blank'>Ver Boleto</a>" : "";
        }
    }
    
    window.onload = formataBoletoEmMeusPedidos();