Terry Upton
  • Member for 5 years, 6 months
  • Last seen this week
"Unknown package has no name defined" composer error on upgrade
10 votes

Very similar to Devin's answer. I came up against this on Friday and I had to follow these steps to resolve this issue. Nuke the vendor folder within the project. rm -rf vendor/ Nuke the composer....

View answer
Categories not adding trailing slash
Accepted answer
4 votes

Whoops! Sorry. As I went to check the code I realised, I was using {{ category.uri }} instead of {{ category.url }}.

View answer
Getting ancestors for manually set parent in template
2 votes

After much help and direction form @RobinSchambach (much appreciated). I have resolved this as follows; {% set currentPage = craft.entries.section('pages').slug('archive').first() %} {% set ...

View answer
PHP 7.0 and 7.1 PDF error with Craft Commerce orders
Accepted answer
2 votes

I came across the same issue yesterday. After a bit of reading and trial and error I found the most elegant way for now is to remove the white space between these elements. <html><head> &...

View answer
Error reporting Freeform submission jumps to top of page
2 votes

By setting the action: "#errortag" seems to stop the form submitting if there are no errors. So instead I have added the following code and this seems to work; {% if form.hasErrors %} {% includejs %}...

View answer
Adding a County input field into Address in Craft Commerce
Accepted answer
2 votes

Currently (Dec '16) I have managed to get around this by re-using the Region/State field and passing this information through as a text field input that the user can enter. <label class="label" ...

View answer
Password validation for resetting password
Accepted answer
2 votes

I wasn't validating againts the field newPassword, only validating against password. Hence why I wasn't getting any feedback. Duplicating the validation for newPassword seems to have resolved this.

View answer
'Unknown error' caused by redirect in htaccess
2 votes

It might be down to the order you have the code in your htaccess file? Did you try putting your code above the Craft rewrite code? # redirect PHP or HTM to no extension RewriteCond %{THE_REQUEST} ^[A-...

View answer
OrderBy section when selecting multiple sections in entries query
1 votes

Since posting the original question, I have also solved this like so: {% set aboutPages = craft.entries.section(['about']).all() %} {% set newsPage = craft.entries.section('newsIndex').one() %} {% set ...

View answer
Showing and hiding details (price, sale price, sku etc)when product variant is selected on details page
1 votes

So, I actually decided a slightly different approach in the end and not sure if it is better or less performant, but I feel gives me a little more flexibility. Basically, more like a 'tabbed' ...

View answer
How can I check if a product has any variant that is on Sale?
1 votes

So the only way I could seem to make this work was as follows: {% set onSale = product.variants|filter(v => v.onSale())|length %} {% if onSale %} code here for sales badge/message etc {% endif %...

View answer
Get related variants from entry and then show products for related variants and then loop only the variants that are related in commerce
1 votes

After some further trial and error I have made this work like so. However, it feels like there is or should be a simpler method....what am I missing or what is a better approach? {% set ...

View answer
Check if cart contains valid products for discount code
1 votes

I have now updated this code for Craft Commerce 2: {% set codeError = null %} {% set cartProductIds = [] %} {% set discountCodeOK = null %} {# THIS CHECKS THE DISCOUNT CODE FOR IF THERE ARE ANY VALID/...

View answer
How can I merge a Modified Date and Time in Twig?
Accepted answer
1 votes

Having done some further testing and research I believe this is a case of having to merge two date objects and ensuring that these are set as date/time objects when merging them into a variable. Here ...

View answer
Dynamic Asset Sub Folder Paths based on section and. if/else or turnery operators
1 votes

So this was a simple fix and not to use {% %} tags but instead to use {{ }} tags. Changing the above logic in the subdirectories filed like so seems to have resolved the issue. {{ section == 'Company'...

View answer
Impossible to invoke a method on array. How to merge multiple objects and keep as objects
1 votes

Here is the complete code that achieves what I want. In case it is useful to anyone else. {% set newsletterImages = newsletter.imagesCongratulations.all() %} {% set newsletterImages = ...

View answer
How to Auto-Generate a Craft Commerce Product Title
1 votes

There is a feature request for this on GitHub. So suggest you go and 'up-vote' it on there to try and get this released. https://github.com/craftcms/commerce/issues/148

View answer
504 error on home page of Craft 3 website
1 votes

I was seeing similar issues and in the end it turned out to be a missing image. In my case it was the Creator (Entity Brand) logo missing. It had been picked but the file was missing locally. After ...

View answer
Get random entries from a section but keep the order of these when splitting the array
1 votes

One way I have achieved this is like so: {% for entry in artists %} {% if loop.first %} <div class="flex flex-wrap items-center"> {% endif %} {% if loop.index == 5 %} </div> ...

View answer
Can the Lightswitch field have a default 'on' setting?
1 votes

This is the mySQL query I have used to update a lightswitch field in the database. UPDATE `table` SET `field_name` = replace(field_name,'original content', 'updated content') for example: UPDATE `...

View answer
Re-using includes when the object type changes (entry vs block) - what is the best method?
1 votes

Perhaps a better method is to include; {% set object = block ?? entry %} at the top of the _includes/matrix/video.htm template and this negates the need to use with { object : entry } in the includes

View answer
Show related entries grouped by category with category title and description
Accepted answer
1 votes

With the use of Tim Kelty's groupBy plugin and some initial direction from @stephenlewis (thanks). The following code seems to have resolved my issue. I am little surprised this couldn't be achieved ...

View answer
Check if cart contains valid products for discount code
1 votes

So some persistence I have this working as follows: {% set currentDiscount = craft.commerce.getDiscountByCode(cart.couponCode) %} {% if currentDiscount %} {% set cartProductIds = [] %} {% ...

View answer
Cart Items Total to include qty of variants
1 votes

After working on this for a while and the help of a fellow developer. The following solution seems to work. Unless anyone can improve on it? {% set cartQty = 0 %} {% for item in cart.lineItems %} ...

View answer