webdna / commerce-bundles Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
I feel like I must be missing something... I don't want to show bundles on their own page, I want to show any bundles that include the product currently being viewed. Getting the bundles that include the current product looks like this:
{# Get the default product variant #}
{% set variant = product.defaultVariant %}
{# Get any bundles associated with this variant #}
{% set bundles = [] %}
{% set allBundles = craft.bundles() ?? null %}
{% for bundle in allBundles.all() %}
{% set bundleProducts = bundle.getProducts() %}
{% for bundleProduct in bundleProducts %}
{% if bundleProduct.id == variant.id %}
{% set bundles = bundles|merge([bundle]) %}
{% endif %}
{% endfor %}
{% endfor %}
That seems like a very long way to go. I see there is no record for the bundles in the craft_relations table, so I can't use
{% set bundles = craft.bundles().relatedTo(variant) ?? null %}
but something short like that would be desired. Is there a better way?
I have Craft 4.7, Commerce 4.4 and Commerce Bundles 2.0.0-beta.7 installed. When I click on add to basket on a bundle I get the following error "Invalid purchasable ID". I'll paste my basket code below as I might be missing something that isn't documented.
{% for bundle in craft.bundles.purchasables(product.variants).with(['bundleImage']).all()|unique %}
<div class="row">
<div class="col-xs-12 col-md-6 col-md-push-6">
{% if bundle.bundleImage is defined and bundle.bundleImage|length %}
<img src="{{ bundle.bundleImage[0].getUrl() }}" alt="{{ bundle.bundleImage[0].title }}" class="books-bundles-bundle-image">
{% endif %}
</div>
<div class="col-xs-12 col-md-6 col-md-pull-6">
<h3>
{{ bundle.title }}
</h3>
<div class="row row-flex items-end">
<div class="col-xs-12 col-md-5">
<div class="books-bundles-bundle-price">
<p>
Total price:
</p>
<h4>
£{{ bundle.price|number_format(2) }}
</h4>
</div>
</div>
<div class="col-xs-12 col-md-7">
<button id="bundle-to-cart" type="submit" class="bundle-submit">
Add all to basket
</button>
</div>
</div>
</div>
</div>
</form>
{% set bundlePrice = bundlePrice + bundle.price %}
{% endfor %}
Any help would greatly be appriciated.
Once the bundle created, all other fields layout did save, but cannot display in the Edit page in CMS.
Added following before the form render works in BundlesController
if($bundleId&&!$bundle) $bundle = Bundle::findOne($bundleId);
kuriousagency\commerce\bundles\elements\Bundle->getStock() raises PHP Error, if a bundle member product is soft-deleted.
getPurchasables() should only return valid purchasable elements (or extend query in _getBundlePurchasables to exclude deleted elements)
Version: 1.2
Is it possible to add a variable I can use in places like the shopping cart:
{% for item in cart.lineItems %}
{%if item.isBundle() %}
do something...
{% endif %}
{% endfor %}
edit: Both Events and Gift Vouchers by Verbb have this variable, if you need some direction on how to implement.
I keep getting this error when I try to save bundles or when I try to save a site. CraftCMS and Craft Commerce 4.
Also not letting me edit bundles, not sure if it's related to permissions by site?
I have been getting an error on production when I go to the bundles plugin, but not on dev.
Craft CMS 3.5.11.1
Bundles 1.1.4
Local is php 7.3.15
Production is php 7.4.11
Any idea what this error means?
Next yii\base\InvalidConfigException: Failed to instantiate component or class "kuriousagency\commerce\bundles\assetbundles\bundles\BundlesAsset". in /srv/users/scradmin/apps/production/vendor/yiisoft/yii2/di/Container.php:455
Stack trace:
#0 /srv/users/scradmin/apps/production/vendor/yiisoft/yii2/di/Container.php(380): yii\di\Container->getDependencies('kuriousagency\\c...')
#1 /srv/users/scradmin/apps/production/vendor/yiisoft/yii2/di/Container.php(165): yii\di\Container->build('kuriousagency\\c...', Array, Array)
#2 /srv/users/scradmin/apps/production/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('kuriousagency\\c...', Array, Array)
#3 /srv/users/scradmin/apps/production/vendor/yiisoft/yii2/web/AssetManager.php(264): yii\BaseYii::createObject(Array)
#4 /srv/users/scradmin/apps/production/vendor/yiisoft/yii2/web/AssetManager.php(237): yii\web\AssetManager->loadBundle('kuriousagency\\c...', Array, true)
#5 /srv/users/scradmin/apps/production/vendor/yiisoft/yii2/web/View.php(287): yii\web\AssetManager->getBundle('kuriousagency\\c...')
#6 /srv/users/scradmin/apps/production/vendor/twig/twig/src/Extension/CoreExtension.php(1499): yii\web\View->registerAssetBundle('kuriousagency\\c...')
#7 /srv/users/scradmin/apps/production/vendor/craftcms/cms/src/helpers/Template.php(92): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\web\View), 'registerAssetBu...', Array, 'method', false, false)
#8 /srv/users/scradmin/apps/production/storage/runtime/compiled_templates/8c/8cecc20069d7eea9227d7bfb2038b047de843f83154739e1ee336f778d9a963c.php(96): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\web\View), 'registerAssetBu...', Array, 'method')
#9 /srv/users/scradmin/apps/production/vendor/twig/twig/src/Template.php(405): __TwigTemplate_e9210a7d670ee12fade609d193f1fea50d2c47707b56f702aa540d8afcca5a18->doDisplay(Array, Array)
#10 /srv/users/scradmin/apps/production/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#11 /srv/users/scradmin/apps/production/storage/runtime/compiled_templates/c6/c64ec0ecb1bd71dae8d92f328a72937215c14ad327baad6526860a66b6e99df9.php(38): Twig\Template->display(Array)
#12 /srv/users/scradmin/apps/production/vendor/twig/twig/src/Template.php(405): __TwigTemplate_39ec66be56c751b70eb3fc1f098dbbc180edba51e11cc13ebcd923d88db11724->doDisplay(Array, Array)
#13 /srv/users/scradmin/apps/production/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#14 /srv/users/scradmin/apps/production/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
#15 /srv/users/scradmin/apps/production/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#16 /srv/users/scradmin/apps/production/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#17 /srv/users/scradmin/apps/production/vendor/craftcms/cms/src/web/View.php(392): Twig\Environment->render('commerce-bundle...', Array)
#18 /srv/users/scradmin/apps/production/vendor/craftcms/cms/src/web/View.php(453): craft\web\View->renderTemplate('commerce-bundle...', Array)
#19 /srv/users/scradmin/apps/production/vendor/craftcms/cms/src/web/Controller.php(251): craft\web\View->renderPageTemplate('commerce-bundle...', Array, 'cp')
#20 /srv/users/scradmin/apps/production/vendor/craftcms/cms/src/controllers/TemplatesController.php(100): craft\web\Controller->renderTemplate('commerce-bundle...', Array)
#21 [internal function]: craft\controllers\TemplatesController->actionRender('commerce-bundle...', Array)
#22 /srv/users/scradmin/apps/production/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#23 /srv/users/scradmin/apps/production/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#24 /srv/users/scradmin/apps/production/vendor/craftcms/cms/src/web/Controller.php(189): yii\base\Controller->runAction('render', Array)
#25 /srv/users/scradmin/apps/production/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('render', Array)
#26 /srv/users/scradmin/apps/production/vendor/craftcms/cms/src/web/Application.php(285): yii\base\Module->runAction('templates/rende...', Array)
#27 /srv/users/scradmin/apps/production/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('templates/rende...', Array)
#28 /srv/users/scradmin/apps/production/vendor/craftcms/cms/src/web/Application.php(270): yii\web\Application->handleRequest(Object(craft\web\Request))
#29 /srv/users/scradmin/apps/production/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#30 /srv/users/scradmin/apps/production/public_html/index.php(21): yii\base\Application->run()
#31 {main}
2020-11-03 20:49:36 [-][1][cf243396014b66b91edfb57a49f12323][info][application] $_GET = [
'p' => 'admin/commerce-bundles'
]
I checked in "customize" screen of bundle list (cogwheel icon) and there is no option for adding bundle link (like entries have - globe icon) as column of list.
I've got a commerce site using bundles that uses hasUnlimitedStock for quite a bit of logic throughout the checkout process. It appears that Bundle elements don't have this property currently, which, when checking out, allows the order to be placed, but throws this error and doesn't take the customer from the payment page to the order summary page.
Getting unknown property: kuriousagency\commerce\bundles\elements\Bundle::hasUnlimitedStock
By hacking the elements/Bundle.php file and adding public $hasUnlimitedStock;
after line 75, the error goes away and order completes as expected. Is it possible you could add this property so I don't have to hack future versions of this plugin?
Do you have any intention or timeline of updating this plugin for Craft Commerce 4?
Since upgrading to the latest commerce bundles we have been getting the following error while trying to save a bundle:
Return value of kuriousagency\commerce\bundles\elements\Bundle::getPrice() must be of the type float, string returned
For the purpose of saving the bundle we've made a temporary fix to line 460 of Bundle.php:
return floatvar($this->price);
Can you please advise if there is a proper way to address this issue, or if there will be an update available?
Versions:
Commerce Bundles: 1.2.1
Craft Commerce Pro: 3.2.14.1
Craft: 3.6.2
PHP: 7.4.14
Hello,
When trying to save any new product bundle, there is an Type error saying that the return value of BundlesController::actionSave() must be of type yiilweb\Response, but null returned (please see screenshot attached).
Is anyone else have encountered the same issue, any workaround to fix this?
Thanks!
Plugin version: 2.0.0-beta.3
Craft version: 4.5.7
This plugin is still showing as a beta release, but is it considered stable now for Craft 4 sites?
When I create a bundle entry and not all the required fields are filled out all of the content is erased from every field. I would expect this to provide an error and not delete all the content like a typical craft entry does.
The filed db/BundleQuery.php is throwing an error when running the inner join command.
Instead of using the bundles_purchasables.bundeId field it is trying to use "bundleid" (all lower case).
The reason for that is because the field name is not between quotes and Postgres is changing it.
In order to avoid it I made a small adjustment to the file on line 188 with this change:
Original:
"bundles_bundles.id = bundles_purchasables.bundleId"
Update
'bundles_bundles.id = bundles_purchasables."bundleId"'
System Info:
PHP version | 7.4.13
OS version | Linux 4.19.121-linuxkit
Database driver & version | PostgreSQL 12.5
Craft edition & version | Craft Pro 3.5.17.1
Craft Commerce | 3.2.13.2
Bundles | 1.2
Hi,
I have a product page which displays a dropdown of different variants, in order to add the product to the cart.
These variants are also sometimes a part of a bundle, so I'd like to display the related bundles on this page too, but I can't figure out how to do it.
Any ideas would be appreciated.
I've tried the following (looping through the variants) without any luck.
{% set bundles = bundles.relatedTo({
sourceElement: variant,
field: 'purchaseables.purchasableId'
}).all() %}
When installing this plugin with Composer 1, the following deprecation notice is output:
Deprecation Notice: Class
kuriousagency\commerce\bundles\assetbundles\Bundles\BundlesAsset
located in./vendor/kuriousagency/commerce-bundles/src/assetbundles/bundles/BundlesAsset.php
does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0.
Composer 2 was released on October 24, and is now the default version that will be installed, so itβs critical that this gets resolved ASAP, or people will start getting Class not found
errors.
To fix, run the following command:
> git mv src/assetbundles/bundles src/assetbundles/Bundles
Then commit your change and tag a new release.
(Note that you must use the git mv
command, as Git tends to not notice case-sensitive file renames otherwise.)
How can i add bundle to the shopping cart?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.