We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Re: Print cart item in table format or export as PDF or CSV

Print cart item in table format or export as PDF or CSV

azieaziz14
Tourist
6 0 2

Hi,

 

I would like to know if there is any app or solution that can print the items in the cart into a table format, or export/save the cart as PDF or CSV?

 

Your help is really appreciated.

 

Thanks,

Azie

Replies 2 (2)

EcomGraduates
Shopify Partner
862 71 126

To export your cart data as a CSV file, you can use a simple JavaScript solution. This works by grabbing the contents of the cart using Shopify's fetch API, then formatting that data into a CSV file that you can download. It's straightforward to set up and will allow customers to save their cart in CSV format.

 

 Like + accept if this helped |
 Theme: EcomifyTheme |
️ Get An Audit: Here



EcomGraduates
Shopify Partner
862 71 126

example  

function exportCartToCSV() {
    fetch('/cart.js')
    .then(response => response.json())
    .then(cart => {
        let csvContent = "data:text/csv;charset=utf-8,Product Name,Quantity,Price\n";
        cart.items.forEach(item => {
            csvContent += `${item.title},${item.quantity},${item.price / 100}\n`;
        });
        let encodedUri = encodeURI(csvContent);
        let link = document.createElement("a");
        link.setAttribute("href", encodedUri);
        link.setAttribute("download", "cart.csv");
        document.body.appendChild(link);
        link.click();
    });
}

 Like + accept if this helped |
 Theme: EcomifyTheme |
️ Get An Audit: Here