Giter VIP home page Giter VIP logo

craft-commerce-product-bundles's Introduction

Bundles Plugin for Craft CMS 3 with Craft Commerce 2 & 3

Combine multiple products into a purchasable bundle to sell these for a special price. Thanks to the inspiration coming from the existing Commerce Bundles plugin, this plugin allows you to create bundles from products and not just their variants. Users can now order bundles and choose their desired variant, eg. shirt size M with trousers size L.

Requirements

This plugin requires:

  • Craft CMS 3.2 or later
  • Craft Commerce 2.1, 3.1 or later

Installation

This plugin can either be installed through the Plugin Store or using Composer.

Plugin Store

  • In the Craft Control Panel, go to Settings -> Plugins
  • Search for 'Commerce Product Bundles'
  • Hit the "Install" button

Composer

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Download the plugin using Composer

     composer require tde/commerce-product-bundles
    
  3. In the Craft Control Panel, go to Settings โ†’ Plugins

  4. Hit the "Install" button for 'Commerce Product Bundles'.

Usage

The "Product bundles" navigation item will be added in the subnav of Commerce. Add your desired bundles and set the new price. Through the plugin settings it is also possible to add custom fields to enhance the user experience of the bundles and provide more information.

Add product bundle in CP

Twig example

The plugin is designed to promote product bundles from within the product detail page. When viewing product A, the user may be encouraged in buying a bundle containing product A and product B. The Twig example below illustrates how to render bundles in a product detail page:

Twig example

{# templates/shop/products/_entry.html #}

{% set productBundles = craft.commerceProductBundles.getProductBundles(product) %}
{% if productBundles|length %}
    <h3>Bundle tips</h3>
    {% for productBundle in productBundles %}
        <form method="POST">
            {{ csrfInput() }}
            {{ redirectInput('shop/cart') }}
            {{ hiddenInput('action', 'commerce/cart/update-cart') }}
            {{ hiddenInput('qty', 1) }}
            {{ hiddenInput('purchasableId', productBundle.id) }}
    
            <h4>{{ productBundle.title }}</h4>
    
            {% for product in productBundle.getProducts() %}
                <h5>{{ product.title }}</h5>

                {% if product.variants|length > 1 %}
                    <select name="options[productBundleProductsVariantIds][]">
                        {% for purchasable in product.variants %}
                            <option value="{{ purchasable.id }}">{{ purchasable.description }}</option>
                        {% endfor %}
                    </select>
                {% else %}
                    {{ hiddenInput('options[productBundleProductsVariantIds][]', product.variants[0].id) }}
                {% endif %}

                {% if not loop.last %}
                    <span>+</span>
                {% endif %}
            {% endfor %}

            {{ productBundle.price|commerceCurrency(cart.currency) }}
            <input type="submit">Add to cart</button>
        </form>
    {% endfor %}
{% endif %}

Make sure to disable product variants if they are out of stock.

Field type

Since 1.0.3 there is also a custom field type available to add product bundles directly into your content.


Brought to you by TDE

craft-commerce-product-bundles's People

Contributors

jerome2710 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.