Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»A Lightweight Cart Package for Laravel

    A Lightweight Cart Package for Laravel

    June 24, 2024

    The binafy/laravel-cart package adds the ability to add shopping cart functionality to Laravel applications. It simplifies storing and managing cart items, supports storing multiple item types, and more:

    Features:

    Secure card information storage and management
    Support for multiple payment gateways
    Recurring payment and subscription management
    Robust validation and error handling
    Highly customizable and flexible architecture

    From the package’s documentation, here’s an example of retrieving a cart for a given user and adding an item to the cart:

    $cart = Cart::query()->firstOrCreate([‘user_id’ => $user->id]);
    $cartItem = new CartItem([
    ‘itemable_id’ => $itemable->id,
    ‘itemable_type’ => $itemable::class,
    ‘quantity’ => 1,
    ]);

    $cart->items()->save($cartItem);

    // Or create and store
    Cart::query()->firstOrCreateWithStoreItems(
    item: $product,
    quantity: 1,
    userId: $user->id
    );

    This package also allows you to store multiple items in the cart, and the cart items are polymorphic model associations. You can access the underlying model associated with the CartItem using the itemable() method:

    $cartItem->itemable()->first();

    You can learn more about this package, get full installation instructions, and view the source code on GitHub.

    Related: GetCandy E-commerce Package for Laravel

    The post A Lightweight Cart Package for Laravel appeared first on Laravel News.

    Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleDataStax releases a number of updates to better facilitate RAG implementation
    Next Article Setting up B2B commerce with Shopify

    Related Posts

    Machine Learning

    Salesforce AI Releases BLIP3-o: A Fully Open-Source Unified Multimodal Model Built with CLIP Embeddings and Flow Matching for Image Understanding and Generation

    May 16, 2025
    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 16, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Connect Amazon Q Business to Microsoft SharePoint Online using least privilege access controls

    Development

    10 rules for building developer tools that feel like magic

    Development

    CISA Urges Federal Agencies to Patch Versa Director Vulnerability by September

    Development

    CVE-2025-3953 – WordPress WP Statistics Unauthenticated Settings Modification Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    Machine Learning

    UniME: A Two-Stage Framework for Enhancing Multimodal Representation Learning with MLLMs

    April 29, 2025

    The CLIP framework has become foundational in multimodal representation learning, particularly for tasks such as…

    76% of Companies Improved Their Cyber Defenses to Qualify for Cyber Insurance

    June 29, 2024

    Recent Windows 11 update lets you disable profanity filter in voice typing

    April 29, 2025

    CVE-2023-31585 – Grocery-CMS-PHP Unauthenticated File Upload Vulnerability

    May 8, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.