Jump to content

how get data cart to genarte pdf ?


Recommended Posts

Hi,

in shipping cart i see my cart, 

I would like créate button générate pdf cart quick without order.

i dump the cart:

acces_panier.thumb.png.68174badbf882b05408894a07ceacfaa.png

 

How i cant get the data cart to PDF ? 

is possible to genarate this dump top pdf ?

thank's for reply

Link to comment
Share on other sites

I try this:

 

<div id="_desktop_cart">

    <script type="text/javascript" src="https://mydomain.com/themes/classic/modules/ps_shoppingcart/jsPDF/examples/js/jquery/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="https://mydomain.com/themes/classic/modules/ps_shoppingcart/jsPDF/examples/js/jquery/jquery-ui-1.8.17.custom.min.js"></script>
    <script type="text/javascript" src="https://mydomain.com/themes/classic/modules/ps_shoppingcart/jsPDF/dist/jspdf.debug.js"></script>
    <script type="text/javascript" src="https://mydomain.com/themes/classic/modules/ps_shoppingcart/jsPDF/examples/js/basic.js"></script>
  
  
    <script>
      function genPDF(panier){
  console.log("kkk");
          var doc = new jsPDF();
          doc.text(20, 20, 'Hello world!');
          doc.text(20, 30, 'ytoto');
          doc.addPage();
          doc.text(20, 20, panier);
  
          // Save the PDF
          doc.save('monpdf.pdf');
      }
  
      </script>
  
  
  
    <div class="blockcart cart-preview {if $cart.products_count > 0}active{else}inactive{/if}" data-refresh-url="{$refresh_url}">
      <div class="header">
        {if $cart.products_count > 0}
          <a rel="nofollow" href="{$cart_url}">
        {/if}
          <i class="material-icons shopping-cart">shopping_cart</i>
          <span class="hidden-sm-down">{l s='Cart' d='Shop.Theme.Checkout'}</span>
          <span class="cart-products-count">({$cart.products_count})</span>
  <br/>
   <a href="javascript:genPDF('$cart')" class="button">Run Code</a></p>
        {if $cart.products_count > 0}
          </a>
        {/if}

 

panier is not here

Link to comment
Share on other sites

I try this

 

<div id="_desktop_cart">


  <div class="blockcart cart-preview {if $cart.products_count > 0}active{else}inactive{/if}" data-refresh-url="{$refresh_url}">
    <div class="header">
      {if $cart.products_count > 0}
        <a rel="nofollow" href="{$cart_url}">

      {/if}
        <i class="material-icons shopping-cart">shopping_cart</i>
        <span class="hidden-sm-down">{l s='Cart' d='Shop.Theme.Checkout'}</span>
        <span class="cart-products-count">({$cart.products_count})</span>

<div id="panier">
   {$cart nofilter}
</div>

        <script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
        <script>console.log(cart)</script>
<script>
                var pdf = new jsPDF('p', 'pt', 'letter');
                pdf.html(document.getElementById('panier'), {
                        callback: function (pdf) {
                                var iframe = document.createElement('iframe');
                                iframe.setAttribute('style', 'position:absolute;right:0; top:0; bottom:0; height:100%; width:500px');
                                document.body.appendChild(iframe);
                                iframe.src = pdf.output('datauristring');
                        }
                });
</script>

<!-- {$cart|dump} -->
      {if $cart.products_count > 0}
        </a>
      {/if}
    </div>
  </div>
</div>

I have a pdf but the $car is array, how cant easy to have html deploy array ?

is use this lib:

 

https://github.com/eKoopmans/html2pdf.js

Edited by kod (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...