What's your biggest current challenge? Have your say in Community Polls along the right column.

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
Visitor
2 0 0

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
784 68 112

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.

 


 If this fixed your issue, likes and accepting as a solution are highly appreciated
|  Build an online presence with our custom-built Shopify Theme: EcomifyTheme
|  Check out our reviews: Trustpilot Reviews
|  We are Shopify Partners: EcomGraduates Shopify Partner



EcomGraduates
Shopify Partner
784 68 112

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();
    });
}

 If this fixed your issue, likes and accepting as a solution are highly appreciated
|  Build an online presence with our custom-built Shopify Theme: EcomifyTheme
|  Check out our reviews: Trustpilot Reviews
|  We are Shopify Partners: EcomGraduates Shopify Partner