Skip to content

Add "Add to cart" button to product list page#36

Merged
arjankc merged 1 commit into
mainfrom
copilot/fix-28
Aug 21, 2025
Merged

Add "Add to cart" button to product list page#36
arjankc merged 1 commit into
mainfrom
copilot/fix-28

Conversation

Copilot AI commented Aug 21, 2025

Copy link
Copy Markdown
Contributor

This PR adds "Add to cart" functionality directly to the product list page (product.php), allowing users to add items to their cart without having to navigate to the individual product detail pages.

Changes Made

  • Added "Add to cart" button to each product card in the product list
  • Placed in the existing empty block2-txt-child2 div that was previously unused
  • Reuses existing cart logic from carthandler.php with identical URL parameters
  • Maintains consistent styling using the same CSS classes as the detail page button

Implementation Details

The button uses the same onclick handler pattern as the existing implementation in details.php:

<button onclick="location.href='carthandler.php?cart_id=<?php echo $final['id'] ?>&cart_name=<?php echo $final['name'] ?>&cart_price=<?php echo $final['price'] ?>'" 
        class="flex-c-m stext-101 cl0 size-101 bg1 bor1 hov-btn1 p-lr-15 trans-04">
    Add to cart
</button>

User Experience Improvement

  • Users can now add products to cart directly from the product listing
  • No need to visit individual product pages for simple cart additions
  • Maintains existing "More Details" functionality for users who want product information
  • Consistent styling and behavior with existing cart functionality

Technical Notes

  • Only 3 lines of code added to accomplish the requirement
  • No changes needed to existing carthandler.php logic
  • Maintains all existing functionality and styling
  • PHP sessions and cart management already properly configured

Fixes #28.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI commented Aug 21, 2025

Copy link
Copy Markdown
Contributor Author

@arjankc 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@arjankc arjankc marked this pull request as ready for review August 21, 2025 05:20
@arjankc arjankc merged commit ac8f3c0 into main Aug 21, 2025
1 check passed
Copilot AI changed the title [WIP] add to cart in product list page Add "Add to cart" button to product list page Aug 21, 2025
Copilot AI requested a review from arjankc August 21, 2025 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add to cart in product list page

2 participants