# Question
Title: Assets randmonly asked me to update without me updating
I'm on Assets 2.2.2. Today it told me to update so I clicked the update button. This happened:

```
A Database Error Occurred
Error Number: 1146
Table 'db509793644.exp_assets' doesn't exist
UPDATE exp_assets SET file_path = REPLACE(file_path, "}/", "}")
Filename: third_party/assets/upd.assets.php
Line Number: 298

```

Now in Add-ons -\> Modules I get @@@VERSION@@ as the version. No clue on this one...

# Answer
> 1 votes
Assets doesn't have any sort of self-updating capability. Moreover, “@@@VERSION@@@” is a flag Assets only uses in its source code. It gets replaced with the actual version number through our build script, before it ever becomes a downloadable .zip on Devot:ee.

I have no idea what's going on here, but it smells fishy. You should really take some time to investigate where your Assets files came from, and how they “randomly” made it to your server.

# Answer
> 0 votes
This errors is pretty specific. It says your 'db509793644.exp\_assets' table doesn't exist.

Get into phpmyadmin or whatever tool you use for navigating your database and look for "db509793644.exp\_assets". Is that the correct name of your table? Specifically, the "db509793644" part?

If that is the correct table name and the table is not there, you'll need to restore from backup. If you don't have one, check with your host. They will most likely be able to pull from their backup. You might want to have them restore the whole site to the state it was at before the update...

---
Tags: assets
---


# Question
Title: Freeform Pro - Channel Entry Fieldtype - Custom error page
This is partially related to this question: Additional parameters while using Freeform Pro Fieldtype

I can't see these options in the Freeform docs, but it seems if you add parameters to the single tag some do output. http://www.solspace.com/docs/freeform/channel\_entry\_fieldtype/

Eg. short name of field is channel\_field

```
{channel_field}

```

To add a custom class name to all forms in the template:

```
{channel_field form:class="your_class_name"}

```

This outputs the form from composer including the custom class name.

Parameters for the form tag pair are here, including the option of a custom error page: http://www.solspace.com/docs/freeform/form/#error\_page

But this does not work:

```
{channel_field error_page="path_to/template"}

```

How can I specify a custom error page while using the freeform field type?

This question is directed at Solspace, but it would be great if anyone else could help.

\** Edit 11 Feb 2014 \** Thanks @Solspace. I'd forgotten I've actually set this up already. I have a custom Composer Template assigned to this form with these Template Params:

* Param Name: error\_page
* Param Value: site/form-error

But I hadn't realised this custom page was working as the error page URL is: `http://example.co.uk/?ACT=72`

Rather than: `http://example.co.uk/form-error/`

It looks like you're handling the error template display during a form submission method and not redirecting?

Now I know where the error page is coming from I've got an unrelated issue why this isn't working. I'll raise a support ticket.

# Answer
You can actually get the raw form\_id from the fieldtype tag like this:

```
{channel_field:form_id}

```

You can use that inside a regular `{exp:freeform:form}` tag as a parameter, which should allow you access to all of the params of freeform:form. I've done this once before. I don't recall if you need embeds/stash to get around parse order issues.
> 1 votes

# Answer
If you create a **custom Composer Template** to go with your Composer form, you can set the same parameters as used by `{exp:freeform:form}`. From the in-add-on instructions:

> **Template Params**
> Add default tag params composer output. These can be any parameters available to {exp:freeform:form}.
> *These will override anything set by Freeform Composer.*

**Additional information**: The Composer templates are created in Freeform from the "*Composer Templates*" tab, and a custom Composer Template is associated with your Composer form in the top left dropdown in the Composer Editor UI in the CP ("*Forms*" tab).
> 1 votes

---
Tags: solspace-freeform, solspace
---


# Question
Title: Channel Form with Matrix File Upload Field
EE v2.7.3 Matrix v2.5.8

I have a Channel:Form where I need to do a ton of custom styling, so I have manually built the form markup, using exactly what is rendered out by {field:my\_matrix\_field}.

I am not able to upload a new file or replace an existing file through this method.

I can: Upload files in the control panel Upload files by using {field:my\_matrix\_field} inside the form Upload files by using my own markup tied to a single, non-matrix file field. Post & updated data in text fields within the matrix field, using my own markup.

I cannot: Upload files using my own markup to a matrix field.

Markup created by {field:my\_matrix\_field}:

```
<input type="file" name="cb-video[row_id_22][col_id_7]" class="file-chooser">
<input type="hidden" name="cb-video[row_id_22][col_id_7][existing]" value="logo.jpg|3" class="existing_file">

```

Markup created by me:

```
<input type="file" name="cb-video[row_id_22][col_id_7]" class="file-chooser">
<input type="hidden" name="not_cb-video[row_id_22][col_id_7][existing]" value="logo.jpg|3" class="existing_file">

```

Notice I change the name attr of the hidden field to be prepended with "not\_". This mimicks what the Matrix JS does to file fields on edit. The {field:my\_matrix\_field} version will successfully post the data and my markup will not.

Am I missing an additional hidden field or JS file that should be included? I feel like it should work with the manually created markup, so long as it is identical. It works with the other field types just fine.

Thanks!

# Answer
I wrote that part of JS some time ago, but if memory serves, then the "not\_" prefix was being applied only when "Delete file" link was clicked. It was done so that the Matrix PHP part would not find the file it was looking for and would delete it then. The reason for this JS manipulation is so that the "delete" action is undoable (simply by removing the "not\_" prefix).

So just applying "not" without user choosing to delete the file is not the correct way to do this, as the script assumes the file was deleted by the user.
> 1 votes

---
Tags: matrix, safecracker, file-uploads, channel-form, safecracker-file
---


title: Low Variables, Matrix and Playa

text:
# Question
Title: Low Variables, Matrix and Playa
I've got a Low Variables group setup called 'Widget sources'.

Inside this group I have 6 Low Variables, all Playa fieldtypes.

I've got some channel entries selected so there are relationship in the system...

I have a Matrix field type setup in a Channel field group which points to my Low Variable group. Multiple selections set to yes.

When I try to publish a new entry in my channel, and create a new Matrix row, my Low variable field type column is blank?

Should I be able to select something here?

What am I doing wrong?

See screenshots attached.

Thanks

Sean

Screenshots:

http://cl.ly/TphQ

http://cl.ly/TpNX

http://cl.ly/TqMd

# Answer
I'll quote the docs here:

> Please note that only *non-hidden* and variables with *early parsing disabled* show up in the variable list in the Publish Form.

So, make sure the vars you want to select are not hidden and have early parsing disabled.
> 2 votes

---
Tags: matrix, playa, low-variables
---


title: 2.7 Update Error with PT Fieldtype

text:
# Question
Title: 2.7 Update Error with PT Fieldtype
Just upgraded from 2.5.5 to 2.7 Not a smooth upgrade as it whitescreened - when I turned errors on it gave me this:

```
Fatal error: Class PT_Fieldtype contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (EE_Fieldtype::display_field) in /home/foobar/public_html/foobar/system/expressionengine/third_party/pt_field_pack/pt_fieldtype.php on line 148

```

Yes it was still running the old field pack but by then I'd not upgraded any third party modules yet.

I'm still running PHP 5.2.15 incase that matters here. Clues?

Thanks John

edit: I've just rolled back to 2.5.5 (and 2.7 failed again) but I can report that my P&T fieldtypes are 1.0.3

# Answer
> 12 votes
Grab the latest P&T Field Pack. They fixed it recently.

# Answer
> 12 votes
In EE 2.7, each class extending `EE_Fieldtype` is required to implement a display\_field() function.

So either you implement that function with no actual implementation if you just want the error to go away

```
public function display_field($data)
{
 // NOTE: Placeholder
}

```

or wait for the fieldtype developers to implement the function so as to be compatible to the new EE version.

# Answer
> 7 votes
Here's how to upgrade an existing EE install with P&T fieldtypes.

After upgrading EE you'll get this error when visiting the modules section:

```
Fatal error: Class PT_Fieldtype contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (EE_Fieldtype::display_field) in /third_party/pt_field_pack/pt_fieldtype.php on line 148

```

To fix:

1. Download the latest fieldpack and copy the files into your install
2. Add this code to /third\_party/pt\_field\_pack/pt\_fieldtype.php (just below the constructor):

```
public function display_field($data) {}

```
3. Navigate to Addons -\> Fieldtypes and install all of the new fieldtypes (the ones that start with FieldPack - blabla. Doing this will automatically uninstall the old fieldtype and change the existing fields you have to use the new fieldtype.
4. Delete the old fieldtype files (ie. rm -rf third\_party/pt\_\* + webroot/themes/third\_party/pt\_\*)

Voilà - finished!

# Answer
> 3 votes
P&T Field Pack has been renamed into/superseded by Field Pack.

---
Tags: pixelandtonic, field-pack
---


title: Database Error (Matrix 2.4.3)

text:
# Question
Title: Database Error (Matrix 2.4.3)
Get the following error when clicking on Add-Ons/Fieldtypes/Matrix. Can anyone help? Thanks.

A Database Error Occurred Error Number: 1060

Duplicate column name 'var\_id'

ALTER TABLE exp\_matrix\_cols ADD var\_id INT(6) UNSIGNED AFTER field\_id, ADD INDEX (var\_id)

Filename: third\_party/matrix/ft.matrix.php

Line Number: 467

**Update**

Updated EE to 2.6.1 and updated all Add-ons I have installed (left Matrix for last). Tried updating Matrix to 2.5.5 and now get the following error when trying to edit any entry:

A Database Error Occurred Error Number: 1054

Unknown column 'is\_draft' in 'where clause'

SELECT row\_id, col\_id\_21, col\_id\_22, col\_id\_28 FROM exp\_matrix\_data WHERE field\_id = 55 AND entry\_id = 75 AND is\_draft = 0 ORDER BY row\_order ASC

Filename: third\_party/matrix/ft.matrix.php

Line Number: 2912

**Note**

Matrix 2.4.3 is working except that I can't add license key or update.

# Answer
> 4 votes
Here's the response I got from P&T support regarding this error. Solved the issue for me:

```
Take a look at the columns in exp_matrix_data table in the database.

* Does it have a field var_id? If no, then the version you should set is 2.2.
* If yes, does it have a field is_draft? If no, then the version you should set is 2.3
* If yes, then the version you should set is 2.5.10

Now, set the version number we determined in the previous three steps for the Matrix field in the exp_fieldtypes table and go visit the Add-ons -> Fieldtypes -> Matrix page and hit submit.

Everything should be all working now.

```

# Answer
> 3 votes
Upload all the files of Matrix 2.5.5. Then go to Add-Ons \> Fieldtypes \> Matrix to trigger its update script.

---
Tags: matrix
---


title: Membership registration required fields

text:
# Question
Title: Membership registration required fields
Is there a way to prevent the username being a required field for membership registration. Or use the email field to jointly populate the username field? I'm using the Simple Registration addon to create a front end form.

# Answer
When you disable the Username field in the Form Settings tab, Simple Registration will use email address for the username.
> 2 votes

---
Tags: members
---


title: Low Variables in cartthrob arithmetic

text:
# Question
Title: Low Variables in cartthrob arithmetic
Hi is there any posibility to get this working?

```

{exp:cartthrob:arithmetic expression="{option_price_numeric} -({option_price_numeric} * {exp:low_variables:single var='early_bird_discount'} / 100)"}

```

In {exp:low\_variables:single var='early\_bird\_discount'} is 30 in this example I'm getting an "undefined variable" error and I know this is correct but I don't know how exactly get the right result for this

**Update**:

Using the first option Rob Sanchez suggests gives me the following error: **Unparsed EE tags in expression, check parse order.** Perhaps it is important for you that the tag is nested into several tags in an embed template:

```

{exp:channel:entries channel="events" require_entry="yes" entry_id="{embed:entry_id}"}
  {exp:cartthrob:item_options entry_id="{entry_id}"}
    {categories show_group="24"}
      {options}
        {if option_value == "{embed:option}"}

          {if category_id =="160"}
            {if "{event_early_bird_date format='%U'}" >= "{current_time format='%U'}" && "{exp:low_variables:single var='siteA:early_bird_discount'}" >"{embed:another_discount}"}
{!-- ##### --}
              {exp:cartthrob:arithmetic expression="{option_price_numeric} -({option_price_numeric} * {early_bird_discount} / 100)"}
{!-- ##### --}
            {if:else}
              {exp:cartthrob:arithmetic expression="{option_price_numeric} -({option_price_numeric} * {embed:another_discount} / 100) + {embed:membrr_price}"}
            {/if}
          {if:elseif category_id =="161"}
            [....]
          {/if}
          [...]

        {/if}
      {/options}
    {/categories}
  {/exp:cartthrob:item_options}
{/exp:channel:entries}

```

**Update 2**

I figured out the problem I think. early\_bird\_discount is a low variable of siteA but I'm trying use this variable on siteB so using {early\_bird\_discount} does not work here. Is there any possibility to get the global variable from siteA on siteB?

# Answer
> 2 votes
You could try two things:

One is to set this particular Low Variable as Early Parsed (in the variable settings). Then you can call it like this:

```
{exp:cartthrob:arithmetic expression="{option_price_numeric} -({option_price_numeric} * {early_bird_discount} / 100)"}

```

Or you could try adding parse="inward" to the arithmetic tag:

```
{exp:cartthrob:arithmetic parse="inward" expression="{option_price_numeric} -({option_price_numeric} * {exp:low_variables:single var='early_bird_discount'} / 100)"}

```

---
Tags: cartthrob, low-variables, math
---


# Question
Title: Cartthrob shipping rates per category group
Is it possible to have shipping rates for a product's category group?

In our example, we have gift cards of varying denominations. We'd like to charge $3 shipping for the first gift card, but not charge shipping for subsequent gift cards.

We can't use per-order shipping, because they will need separate per item rates for products such as shirts, event registration, etc.

# Answer
Unfortunately, there's currently nothing built into CartThrob that will handle that type of shipping functionality. You would need to create a custom shipping plugin.
> 2 votes

# Answer
Could you reverse-engineer a solution using discounts instead of shipping, which could be applied to a category, or a buy x get x off type scenario? Then your other per item shipping costs could still apply?
> 2 votes

# Answer
I've been able to write my own shipping plugin. Once I polish it up, I'll post it up on github. It does selectable flat rates, item rates, and category rates if you've selected the default flat rate.
> 0 votes

---
Tags: cartthrob, shipping
---


title: Entry not saving with certain words

text:
# Question
Title: Entry not saving with certain words
has anyone experienced an issue with channel entries not saving due to certain words? I'm updating a site with new content from the client, however when I put the new text in and save, the page just returns me to the front end of the site, without saving the entry. Through trial and error, it will save if I remove one or two words from the text. When I put those words back in, the problem returns.

There doesn't seem to be anything unusual about the words, they just seem to random words Expression Engine doesn't like.

I'm using EE 2.6.0.

Thanks,

# Answer
Generally this is a sign that your server has mod\_security enabled. You'll want to disable it, or have your host do so, or at least loosen up the settings on it.

Basically, mod\_security is seeing words that could be parts of rogue SQL queries coming in via POST, and it blocks them from getting passed to the script as a preventative measure.
> 1 votes

---
Tags: ee2, content
---


# Question
Title: 404 when Sagepay attempts to contact Cartthrob notification URL in Nginx
> https://xxx.xxx.xxx/themes/third\_party/cartthrob/lib/extload.php

works fine, but

> https://xxx.xxx.xxx/themes/third\_party/cartthrob/lib/extload.php/sage\_s

returns a 404.

My nginx server config is as follows:

```
server {
  listen 443 default_server ssl;
  ssl_certificate /etc/nginx/ssl/xxx_xxx_xxx.pem;
  ssl_certificate_key /etc/nginx/ssl/xxx_xxx_xxx.key;
  server_name xxx.xxx.xxx;
  root /sites/xxx_xxx_xxx/public_html;

  access_log /var/log/nginx/xxx_xxx_xxx-access.log;
  error_log  /var/log/nginx/xxx_xxx_xxx-error.log info;

  location / {
    index index.php;
    try_files $uri $uri/ @ee;
  }

  location @ee {
    rewrite ^(.*) /index.php?$1 last;
  }

  location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php5;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

```

# Answer
> 3 votes
try next config:

```
server {
  listen 443 default_server ssl;
  ssl_certificate /etc/nginx/ssl/xxx_xxx_xxx.pem;
  ssl_certificate_key /etc/nginx/ssl/xxx_xxx_xxx.key;
  server_name xxx.xxx.xxx;
  root /sites/xxx_xxx_xxx/public_html;

  access_log /var/log/nginx/xxx_xxx_xxx-access.log;
  error_log  /var/log/nginx/xxx_xxx_xxx-error.log info;

  location /themes/third_party/cartthrob/lib/extload.php {
    rewrite ^(.*) /themes/third_party/cartthrob/lib/extload.php?$1 last;
  }

  location / {
    index index.php;
    try_files $uri $uri/ @ee;
  }

  location @ee {
    rewrite ^(.*) /index.php?$1 last;
  }

  location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php5;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

```

# Answer
> 1 votes
Ensure your firewalls allow outbound Port 443 (HTTPS only) & inbound ports 443 (& optionally 80 HTTP) access in order to communicate with our servers (on Test/Live).

Check not a DNS issue if not receiving our (Sage Pays) Notification post.

What are the main differences between the two NotificationURLs?

When acknowledging Sage Pays notification post, when you send the Status, StatusDetail and RedirectURL, make sure you clear your response buffer to remove header code, comments or HTML as Sage Pay Server will expect "Status=" to be first characters in the response.

---
Tags: cartthrob, sagepay, nginx
---


title: How to use AJW Feed Parser?

text:
# Question
Title: How to use AJW Feed Parser?
I'm really stuck on how to get this working. I don't know what I need to include to get the plugin to output data.

Example XML feed:

```
<quote_feed version="1">
    <latest_price>
        <time>13:24:28</time>
        <mid_price>49.00</mid_price>
        <offer_price>50.00</offer_price>
        <bid_price>48.00</bid_price>
    </latest_price>
</quote_feed>

```

What tags to I need to output the bid price for example? Thanks for anyone's help!

Tags I'm using:

```
{exp:ajw_feedparser
    url="feed name"
    cache_refresh="10"
    limit="8"
    debug="true"
    date="pubDate"
}

<p>{mid_price}</p>

{/exp:ajw_feedparser}

```

Error output:

> Cache file exists
>
> Cache file is fresh (51 seconds remaining)
>
> No tags available.

Thanks for your help.

# Answer
> 2 votes
If you want just the child elements of `latest_price`, you need to set it as the root of the loop.

```
{exp:ajw_feedparser
    url="feed name"
    cache_refresh="10"
    limit="8"
    debug="true"
    itempath="/quote_feed/latest_price"
}
    <p>{mid_price}</p>
{/exp:ajw_feedparser}

```

---
Tags: xml
---


# Question
Title: Possible to filter Stash List by two custom fields?
I'm retrieving a list and ordering it by a custom field but need to exclude some fields and include others. Essentially it is a case of the EE 'search by custom field' param but using OR not AND....was previously doing this without Stash with Mark Croxton's Search Fields module which unlike native EE does support an 'OR' search.

My question is - how can I replicate this on the Stash list? Is it possible to use Search Fields with Stash? From what I have so far seems not.

# Answer
> 2 votes
EE *does* support OR matching with the channel entries tag parameter:

```
search:body="pickles|shoes"

```

If that's not enough:

**Filtering a Stash list with regular expressions**

You can create your own index column when capturing a resultset as a list. Your index column would concatenate the values you want to filter by.

Cache the list so that you don't need to re-run expensive channel:entries queries each time the template is viewed. I'm using '@' as a delimiter for the index column:

```
{exp:stash:set_list name="cars" parse_tags="yes" limit="500" save="yes" scope="site" replace="no"}
    {exp:channel:entries channel="cars"}
        {stash:index}{marque}@{color}{/stash:index}
        {stash:marque}{marque}{stash:marque}
        {stash:color}{color}{stash:color}
        {stash:reg}{title}{/stash:reg}
    {/exp:channel:entries}
{/exp:stash:set_list}

{!-- get red OR blue AND volkswagen --}
{exp:stash:get_list name="cars" scope="site" match="#^(blue|red)@volkswagen$#" against="index"}
   {reg} <br>
{/exp:stash:get_list}

{!-- get red OR volkswagen --}
{exp:stash:get_list name="cars" scope="site" match="#^red@|@volkswagen$#" against="index"}
   {reg} <br>
{/exp:stash:get_list}

```

**Caveat**

Outputting more than a few hundred entries with channel entries will be expensive in memory and queries the first time your template is viewed and the cache generated. You could write your own optimised query to grab the relevant entries, or if you are trying to filter a large resultset, consider using something like the excellent Low Search.

---
Tags: stash, custom-fields
---


# Question
Title: Safecracker error after upgrading from 2.5.5 to 2.7
I see this in pages where I have Safecracker forms

```
A PHP Error was encountered

Severity: Warning

Message: require_once(/home/dsvrtwo/public_html/system/expressionengine/third_party/safecracker/mod.safecracker.php) [function.require-once]: failed to open stream: No such file or directory

Filename: libraries/Template.php

Line Number: 1011

```

Any idea why it is still pointing to "safecracker"?

In the Channel Form documentation page, I don't see any opening/closing tag documentation. Am I supposed to rename my Safecracker forms?

**UPDATE**: I found this Channel Form examples page.

So I tried renaming my tag to `{exp:channel:form}`.

However, I get 2 new errors

```
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Channel_form_lib::$EE
Filename: safecracker_registration/ext.safecracker_registration.php
Line Number: 125

A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: safecracker_registration/ext.safecracker_registration.php
Line Number: 125

```

# Answer
> 1 votes
ExpressionEngine is not pointing to safecracker, an add-on is. I hope you were upgrading on a development/testing environment. It's one of those cases where you have to wait for all your required add-ons to be compatible with the new version of EE before upgrading.

# Answer
> 1 votes
When you upgrade EE, installer automatically changes your all templates, but it only changes the templates in database. If you use templates in files, you have to change manually all your templates and replace {safecracker} tags with new {exp:channel:form} tags. Actually you can open the template in control panel, and copy/paste the automatically updated code to the template in file. It took my one night and few more grey hairs :) Hope this helps.

# Answer
> 0 votes
I had the exact issue asked by arvinsim , my form templates would not parse at all after my upgrade from 2.5.5 to 2.7 (and php error was the same). I only needed to replace {exp:safecracker} with {exp:channel:form}.

---
Tags: safecracker, 2.7.0
---


title: Cartthrob pro-rata subscriptions

text:
# Question
Title: Cartthrob pro-rata subscriptions
I have a client that wishes to use the cartthrob subscriptions system in a slightly different manner.

Is it possible to have an annual payment at the start of the year and then if someone joins midway through the year for the first payment to be a 'pro-rata' version of the annual total?

So if the annual membership is £300 and a new customer signs up in June, they pay £150 for the first year and then £300 in January, the following year.

Thanks for your help,

Martyn

# Answer
> 1 votes
One possible solution is to create 2 different products: One that has no start date (starts immediately) with a trial price of $150 and a standard price of $300. The other product would have no trial price and would have a start\_date set for the next calendar year.

Another possible solution could be to simply add a trial price to the subscription product as soon as you are "into" the year of $150, and keep the standard price at $300.

Feel free to schedule a Phone/Skype appointment with the CartThrob/Mightybigrobot support team at http://support.mightybigrobot.com. A member of our support team can speak with your personally and will custom tailor a suitable solution to this issue if you think it needs further discussion.

---
Tags: cartthrob
---


# Question
Title: Manipulate custom order data with CT hook during checkout
I'm using CT. When a customer checks out they are required to select a location for where they want to pickup their order. I would like to save both the location's ID and the location's pickup date to custom fields that I'v set on the orders channel. Currently, when a customer selects a location from the select menu the location ID is submitted along with the form. I've written an extension that looks for the cartthrob\_on\_authorize hook. It allows me to get the location ID from the custom field and run a query to get the location date. My question is, how do I save the location date to the order through my extension? I've tired various combinations like this:

"ee()-\>cartthrob-\>cart-\>order-\>set\_custom\_data('order\_pickup\_date', $pickup\_date)"

but nothing like that seems to work. Any help is much appreciated. Thanks!

# Answer
Once the order is authorized (once you've gotten to the on\_authorize hook), custom data isn't going into the order… because the order's basically "done" and not still compiling the data in the order. That said though, you can update the order fairly easily:

If you have an order channel field with the name of `order_pickup_date` do something like this:

```
ee()->load->model("order_model");
$order_data = array(
    'order_pickup_date' => $pickup_date,
);
ee()->order_model->update_order(ee()->cartthrob->cart->order('entry_id'), $order_data);

```

You could also add custom\_data using the pre\_process hook (the order is still being set at that point), which wouldn't require the work above. Either way it's pretty simple once you see it done one time.
> 0 votes

---
Tags: cartthrob, hook, checkout
---


# Question
Title: Updating Order status from "Processing" to "Completed" in Cartthrob
I have a client who wants customers' credit cards authorized but not charged until they have manually verified that the product is available and ready to be shipped.

We're using Cartthrob and Authorize.net and we have a CIM account.

I have followed Cartthrob's instructions on this page: http://cartthrob.com/docs/tutorials/authorize\_later\_with\_vaults/index.html

That page includes this sample template code:

```
{exp:cartthrob:checkout_form
    force_vault="yes"
    force_processing="yes"
}
 {gateway_fields}
 <input type="submit" value="Checkout">
{/exp:cartthrob:checkout_form}

*An admin interface might then look like this:*

<table>
    <thead>
        <tr>
            <th>Order</th>
            <th>Date</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
     {exp:channel:entries channel="orders" status="Processing"}
      <tr>
        <td>{title}</td>
        <td>{entry_date format="%F %j, %Y"}</td>
        <td>
            {exp:cartthrob:checkout_form
                vault_id="{order_vault_id}"
                order_id="{entry_id}"
            }
            <input type="submit" value="Process Order">
            {/exp:cartthrob:checkout_form}
        </td>
      </tr>
    {/exp:channel:entries}
   </tbody>
 </table>

```

With a few tweaks (no tables, I use Stash DRY templating, and so on), I used that code. The orders are being entered with a "processing" status just fine. The sample admin interface code produces the list of entries that were marked "processing" just fine as well but clicking on the "Process Order" button for any of the entries returns this error message:

**Error Number: 1062 Duplicate entry '499' for key 'PRIMARY' INSERT INTO `exp_channel_titles` (`entry_id`, `site_id`, `channel_id`, `author_id`, `forum_topic_id`, `ip_address`, `title`, `status`, `versioning_enabled`, `entry_date`, `edit_date`, `year`, `month`, `day`) VALUES ('499', '1', '22', '1', 0, '127.0.0.1', 0, 'processing', 'y', 1391499771, '20140204024352', '2014', '02', '04') Filename: third\_party/cartthrob/models/cartthrob\_entries\_model.php Line Number: 261**

I'm pretty sure this is MySQL telling me that I'm trying to insert a duplicate entry id in the table that keeps the list of ordered products.

Reading Cartthrob's suggested template code, I can see why I'm getting this error message. The checkout\_form tag creates an entry in the orders channel as well as sending the capture request off to Authorize.net. Since that entry already exists, I'm getting the "duplicate entry for primary key" error message from MySQL. What I need to have happen is an **update** to the particular order in the orders channel that also sends off the "capture" request to Authorize.net.

I'd call Cartthrob for support but I'm currently still working on my local machine (yes, it does talk to Authorize.net) so I'd have to upload it all to a staging site in order for Cartthrob to look at it. I'm also using V2.4 which I know is one version behind but I searched the changelog carefully and none of the fixes seemed to apply here. I'd be happy to be wrong about that but before I go through all the work of updating and uploading, I'd like to know if there's something simpler I could do or if there's no way at all to do this.

Thanks in advance,

Jeanne

# Answer
> 2 votes
> Since that entry already exists, I'm getting the "duplicate entry for primary key" error message from MySQL. What I need to have happen is an update to the particular order in the orders channel that also sends off the "capture" request to Authorize.net.

The form itself should be fine… you've run into a bug with that function.

I haven't yet had time to test the following, but after reviewing the code, I think the following may correct it.

Open the cartthrob \> libraries \> Cartthrob\_payments.php file.

Around line 1806, you'll find something that looks like this:

```
                unset($order_entry);
        }
        else
        {
            $this->add_error(lang('you_do_not_have_sufficient_permissions_to_update_this_order'));
            return FALSE;
        }

```

Change it to this:

```
                unset($order_entry);
            $order_id = $update_order_id; // add this
        }
        else
        {
            $this->add_error(lang('you_do_not_have_sufficient_permissions_to_update_this_order'));
            return FALSE;
        }

```

I think that order\_id variable got wiped out last time we did some juggling to add updating for subscriptions, some of that area of code underwent some big changes. When I get some time I'll test this here… but I think that might do the trick.

---
Tags: cartthrob
---


# Question
Title: Cartthrob Multi Location Settings Manager gives white screen of death
I upgraded CartThrob Pro to 2.4 and EE to 2.7.3 now I get a white screen of death when I try to access the Multi Location Settings Manager module page in the control panel. I uninstalled it and reinstalled it.

I am using the Multi Location Settings Manager to change shipping options for domestic vs. international orders.

I'm not using the HealthCheck accessory.

Anyone else have this problem? Any suggestions for debugging it?

# Answer
> 1 votes
I installed here locally and on one of our remote servers. I found a few small things I fixed, but nothing that I would expect to create the "white screen of death". Barrett also installed in a few locations and didn't have issues, so it may be some specific conflict that's a bit hard to diagnose.

The latest public release is 1.677 of the Multi Location Module, available for free download from cartthrob.com. You might want to make sure that's updated.

Because we can't reproduce this here I suggest you schedule a Phone/Skype appointment with the CartThrob/Mightybigrobot support team at http://support.mightybigrobot.com. A member of our support team can speak with your personally and will custom tailor a suitable solution to this issue.

---
Tags: cartthrob
---


# Question
Title: CRON job not working for subscription with CartThrob 2.5.3
Having a problem with a CRON job.

I made my first subscription on our live site to recur every month. Then I went into the Subscriptions control panel and changed the subscription that I had just made to recur every day so that I could test it. After that I remembered that it needs to have a CRON job on the server so I set it up to use the first method using a shell script listed here: http://cartthrob.com/docs/docs\_subscriptions/#setting-up-rebilling.

I set up the CRON job to run every day at 6:00 AM. Then this morning I received an email with the following text in it:

> CartThrob has noticed that your system folder path does not appear to be set correctly. Please open CartThrob's Extload file and update the URL: extload.php

My system is above web root so I changed the `$system_path` in extload.php to `$system_path = "../system";` which is relative to the `themes` folder. Then I scheduled the CRON job to run a few minutes into the future to see if it would work. The time came and went and there were no new orders placed.

I then checked the subscription next billing date and it was set for today.

Then I thought that perhaps I was using the wrong script for the CRON job so I changed it to method 3 trying PHP's "passthru" function and rescheduled to a few minutes into the future.

Once that was changed I was sent an email when it ran saying "Permission Denied". So then I changed it back to method 1 using the shell script, reschedule, and waited for an order to be processed. Nothing.

I'm using Authorize.net CIM for my payment gateway. Any idea what I'm doing wrong?

Thanks for your help!

Running *ExpressionEngine 2.7.3* with *CartThrob 2.5* on *Media Temple GS*

# Answer
Because solving this may end up being fairly complex I suggest you schedule a Phone/Skype appointment with the CartThrob/Mightybigrobot support team at http://support.mightybigrobot.com. A member of our support team can speak with your personally and will custom tailor a suitable solution to this issue.

Grid server at Media Temple has some php configurations that may be part of the problem. It could have something to do with open\_basedir (but I don't think so) or weird path resolution (which I've seen there too). We've run into some real doozies with MT Grid Server. And who knows, it could be something to do with EE / CT… Schedule a call (provide credentials if possible) and we can take it from there.
> 0 votes

---
Tags: cartthrob, subscriptions, cron
---


title: PayPal API endpoint updates

text:
# Question
Title: PayPal API endpoint updates
For CartThrob and Expresso Store guys, just had this email from PayPal this morning:

---

In an upcoming system upgrade, the following API endpoints will be updated:

* api.paypal.com
* api-3t.paypal.com
* svcs.paypal.com

Please make sure you are ready for this event by consulting with your technology team or individual(s) responsible for your PayPal integration.

### When is this happening?

This upgrade will occur on 26 March 2014 at 5:00 p.m Australian Eastern Daylight Time (AEDT).

*** If you are integrated with a partner or a cart, please view our FAQs for more information.

### What do I need to do?

Your technical team or individual(s) responsible for your PayPal integration will need to examine your current integration and make necessary changes as outlined below.

If your site is:

* Calling our APIs with a hardcoded PayPal API endpoint IP address, rather than using DNS resolution:

+ Impact of upgrade: API calls will timeout or your will encounter an internal error from your system.
    + You need to: Use DNS resolution to access our API endpoints and/or open your firewall to the new IP addresses which will be communicated later.
* Using HTTP methods other than GET, POST, DELETE and PUT:

+ Impact of upgrade: API calls will return HTTP/1.0 400 Bad Request or HTTP Error 405 Method not allowed.
    + You need to: Send the API requests using one of the allowed methods. Heartbeat calls using the HEAD method won’t be allowed.
* Using the HTTP 1.0 protocol:

+ Impact of upgrade: API calls will return HTTP/1.0 400 Bad Request.
    + You need to: Update your code to HTTP 1.1 and include the Host header in the API request.
* Needing firewall changes to allow new IP addresses:
    + Impact of upgrade: API calls will error out if your system responsible for making API calls to PayPal is behind a firewall that uses Access Control List (ACL) rules and limits outbound traffic to a limited number of IP addresses.
    + You need to: Update your firewall ACL to allow outbound access to a new set of IP addresses we will be publishing. Test your integration on Sandbox (see the IP addresses for Sandbox API endpoints). The list of new IP addresses for our Live API endpoints will be posted here when available in January.

---

Will this require add-on updates? And if so, will it affect v1 versions of the software too?

# Answer
This won't impact CartThrob… either version 1x or 2x.
> 1 votes

# Answer
This should not have any impact on Expresso Store (both versions 1.x and 2.x). We use DNS resolution and standard HTTP verbs, so none of the changes above will affect Store.

(and we use PayPal on our own site, so if anything does happen, we will be the first to know about it!)
> 2 votes

---
Tags: expresso-store, cartthrob
---


# Question
Title: CartThrob checkout form returning wrong subdomain
I just upgraded a site from CartThrob 2.1.3 to 2.5 (along with updating EE to 2.7.3). Everything seems to be fine, but I'm having a glitch during the checkout process. It may very well not have anything directly to do with CT, but I'm stumped as to what's going on. Any suggestions would be really appreciated. Here's the situation:

I have set up a subdomain for the upgraded site, for example, beta.testsite.com (the regular site url is formatted like www.testsite.com). During the checkout process, I have an initial https page where the customer enters their name, as well as choosing a shipping option and entering a shipping address. When submitted, that page is supposed to return the second checkout page, where credit card information gets input.

What's happening, though, is that instead of returning https://beta.testsite.com/cart/checkout2, it's returning https://www.testsite.com/cart/checkout2 instead. (www instead of beta)

I've checked the template for the first checkout page, the cart scripts file that gets embedded, and the htaccess file -- none are explicitly calling the www version of the domain.

Any suggestions on what might be the culprit?

(I realize this is a somewhat vague issue with lots of potential variables, but I'm stumped. Thanks in advance.)

# Answer
> 1 votes
1. Make sure you have EE's admin \> general settings \> URL to the root directory of your site is set correctly.
2. Make sure the return parameter on the checkout\_form is something like this:

return="template\_group/template"

And doesn't include a hard coded URL.

There are some other things that could be wrong if this is an MSM site. But the two above are the most common problems.

---
Tags: cartthrob
---


# Question
Title: CartThrob - Coupon or discount for subscriptions?
I'm not seeing any reference in the docs to coupon codes or discounts on subscriptions. Is this possible? More specifically, our project scope includes applying coupon codes to either the *first* month's subscription charge or all subsequent months in a given subscription.

# Answer
> 1 votes
At present there are no coupon/discounts that have been created that do either/or.

The built in settings govern whether or not discounts should be applied on subsequent payments (based on a discount set in the cart on purchase), but there's nothing created at this point that does specifically what you're asking.

I suggest you schedule a Phone/Skype appointment with the CartThrob/Mightybigrobot support team at http://support.mightybigrobot.com. A member of our support team can speak with your personally and discuss possible solution to this issue.

---
Tags: ee2, cartthrob, subscriptions
---


# Question
Title: How to get default language in an add-on?
Is there a way to get the default language set in *Admin -\> General Configuration* in an add-on(module, extension, plugin)?

# Answer
It's a config item, so you can get it using the Config object, thus:

```
ee()->config->item('deft_lang');

```
> 2 votes

---
Tags: multi-language, language
---


# Question
Title: 404 error when trying to list category entries
I've been trying for days to figure this thing out. I'm building a News section in the site, and under news are 3 categories: Updates, Events, Archive. When you click on one of the categories, i want it to list all the entries where it is under that category, but no matter what I try I just get a 404 error.

Here are my settings: Channel short name: news Group Assignments \> Category group: News Category Group Name: News News Categories: updates, events, archive

And here is my current code (though I've tried many many different options and version:

```
<!DOCTYPE html>
<html>
  <head>
      <meta charset="UTF-8">
      {embed="Pages/styles"}
      {embed="Pages/scripts"}
      {exp:channel:entries channel="news" dynamic="no" limit="1"}
      <title>{site_name} - {structure:page:title}</title>
      <meta name='keywords' content='{news-keywords}' />
      <meta name='description' content='{news-description}' />
      {/exp:channel:entries}
  </head>
  <body>
      {embed="Pages/header"}
      <main>
          <nav id="breadcrumbs">{exp:structure:breadcrumb inc_home="no" here_as_title="yes" separator=":"}{/exp:structure:breadcrumb}</nav>
          {exp:channel:entries channel="news" category="{segment_2_category_id}" dynamic="no"}
              <article>
                  <h1>{title}</h1>
                  <p>Author: {author} Posted: {entry_date format="%M %j, %Y"} at {entry_date format='%h:%i %A'}</p>
                  <p>{news-content}</p>
              </article>
          {/exp:channel:entries}
          <aside>
              <ul>
                  <li>Categories</li>
                  {exp:channel:categories channel="news" style="linear"}
                  <li><a href="{path='news/{category_url_title}'}">{category_name}</a></li>
                  {/exp:channel:categories}
              </ul>
          </aside>
      </main>
      {embed="Pages/footer}
  </body>
</html>

```

# Answer
> 1 votes
The channel:entries tag doesn't have a `category_url_title` parameter. If you want to use the URL structure you're after, you'll need to install Low Seg2Cat. Once installed, you can use `{segment_2_category_id}` to get the right category ID associated with the second segment (which points to a category URL title). Add `dynamic="no"` to the tag as well, since you're telling EE what to display, instead of letting EE guess, based on the URI.

Also, you're missing a closing quote on your opening tag. And I think you need to add `style="linear"` to your channel:categories tag, in order to avoid nested `<li>` elements.

So, with Low Seg2Cat installed, this is how it should look:

```
{exp:channel:entries channel="news" category="{segment_2_category_id}" dynamic="no"}
    <article>
        <h1>{title}</h1>
        <p>Author: {author} Posted: {entry_date format="%M %j, %Y"} at {entry_date format='%h:%i %A'}</p>
        <p>{news-content}</p>
    </article>
{/exp:channel:entries}
<aside>
    <ul>
        <li>Categories</li>
        {exp:channel:categories channel="news" style="linear"}
        <li><a href="{path='news/{category_url_title}'}">{category_name}</a></li>
        {/exp:channel:categories}
    </ul>
</aside>

```

---
Tags: entries, 404, categories
---


title: Cartthrob and Zoo visitor

text:
# Question
Title: Cartthrob and Zoo visitor
I'm trying to do a checkout with cartthrob and instantly creating a new member. This really works great so I have a member entry in the members table. But I use zoo visitor and also need a channel entry there. It is described in the docs of cartthrob that it has to work: http://cartthrob.com/docs/tutorials/member-accounts/#addons-for-member-management

Does anybody has a working example for this scenario?

Regards

# Answer
With the hint from Gfive I played around with {exp:zoo\_visitor:sync}. After I recognized that this function uses the wrong site\_id for me I wrote a small plugin which temporarily changes the site\_id especially to my needs. Here is the code:

```

class Custom_Zoo_Sync
{
    public function sync()
    {
        $this->EE =& get_instance();

        $this->EE->load->add_package_path(PATH_THIRD . 'zoo_visitor/');
        $this->EE->load->library('zoo_visitor_lib');
        $this->EE->load->helper('zoo_visitor');

        $real_site_id = $this->EE->config->item('site_id');
        $this->EE->config->set_item('site_id', 1);
        $this->EE->zoo_visitor_lib->sync_member_data();
        $this->EE->config->set_item('site_id', $real_site_id);

    }
}

```

Feel free to comment this solution. Perhaps it is a bad idea to do it this way?
> 0 votes

# Answer
I solved it with {exp:zoo\_visitor:sync}

first screen is for CT to create member account and others (payment select etc). second screen I used {exp:zoo\_visitor:sync} to sync CT member data to zoo\_visitor.

Works great. If needed you could use the second screen to alter or add extra data to zoo\_visitor.
> 0 votes

---
Tags: cartthrob, members, zoo-visitor
---


# Question
Title: Expresso Store - Add product SKU to page title on product detail pages
I'm trying to automate the output of SKU's into the page's title for all my product pages for SEO reasons however I'm struggling on how to go about this.

I'm using SEO lite for outputting page titles and tried the following code:

```
<title>{title} {if store_product_sku}{store_product_sku}{/if} {site_name}</title>

```

Which doesn't appear to work as I'm assuming I need a channel:entries tag or store:product tag, however having tried various combinations of these none of these work either, would appreciate any ideas, here's the other code I've tried:

```
<title>{title}{exp:channel:entries}{exp:store:product}{if store_product_sku}{store_product_sku}{/if}{/exp:store:product}{/exp:channel:entries} {site_name}</title>

```

# Answer
> 3 votes
I'm going to put my comment as an answer.

For the first line you can change `store_product_sku` to `{product_details:store_product_sku}`

For the second line if `{title}` works then IMO you are already in the `exp:channel:entries` so you have duplicated it that is why may not work correctly. Other way it looks fine.

Also you can use short tag `{sku}` so you need to change `store_product_sku` to `sku`

---
Tags: expresso-store, seo
---


# Question
Title: New comment email notification and ‘insert_comment_insert_array’ hook
I hame some input fields on my comment form, that I show for non-registered members. They are: ‘name’, ‘email’ and ‘comment text’.

And my task was to add string “Guest” to text user typed in the field ‘name’. So I created extension where I use ‘insert\_comment\_insert\_array’ hook:

```
public function concat_username($data)
{
    if($data['author_id'] != 0)
        return $data;

    $data['name'] = "Guest ".$data['name'];

    return $data;
}

```

And it works. But new comment email notifications that I receive after new comment was posted contain user name without my string “Guest”.

May be anyone knows what’s wrong?

# Answer
This is likely because the comment notification uses not the database entry for the comment, but the POSTed comment data. The `insert_comment_insert_array` hook only affects what gets inserted into the database.
> 2 votes

---
Tags: email, comments, hook
---


title: Stash - retrieving Matrix field data

text:
# Question
Title: Stash - retrieving Matrix field data
I'm new to Stash and I'm trying to get the data from a Matrix field. The field has two columns, image and video, and there can be more than one matrix row.

I've used the example from the Stash documentation but it's still not working for me. I am getting the non-matrix data fine but not the Matrix items. Can anyone spot what I'm missing?

Thanks.

```
{if segment_2_category_id}
            {exp:stash:set_list name="news_list" parse_tags="yes" parse_depth="2"}
                {exp:channel:entries channel="news" status="open|featured" orderby="date" sort="desc" limit="10" category="{segment_2_category_id}"}
                    {stash:item_title}{title}{/stash:item_title}
                    {stash:item_url}{url_title}{/stash:item_url}
                    {stash:item_date}{entry_date format="%F %d, %Y "}{/stash:item_date}
                    {stash:item_copy}{news_content}{/stash:item_copy}

                    {exp:stash:set_list:nested name="item_media" context="{entry_id}" parse_tags="yes"}
                        {news_videos_images}
                            {stash:item_image}{image}{/stash:item_image}
                            {stash:item_video}{video}{/stash:item_video}
                        {/news_videos_images}
                    {/exp:stash:set_list:nested}

                {/exp:channel:entries}
            {/exp:stash:set_list}
        {if:else}
        {exp:channel:entries channel="news" status="open|featured" orderby="date" sort="desc" limit="10"}
            {title}
        {/exp:channel:entries}
        {/if}

    {exp:stash:get_list name="news_list"}
        <div class="row blog-post-item">

        {exp:stash:get_list:nested name="item_media" context="{item_entry_id}" prefix="nested"}
            <div class="{nested:switch='row|rowAlt'}">
                <p>{item_video}</p>
                <p>{item_image}</p>
            </div>

        {/exp:stash:get_list:nested}

            <div class="row">
                <div class="description col-xs-12">
                    <h2>
                        <span class="date">{item_date}</span>
                        {item_title}
                    </h2>
                    {item_copy}
                    <a class="blue" href="{item_url}" title="{item_title}">Read more</a>
                </div><!-- /description-->
            </div><!--  /row-->

        </div><!-- /row blog-post-item-->
    {/exp:stash:get_list}

```

# Answer
You're trying to use {item\_entry\_id} for the context parameter when outputting your item\_media list, but it doesn't look like it was set? Try adding:

```
{stash:item_entry_id}{entry_id}{/stash:item_entry_id}

```

to news\_list when you're setting it.
> 0 votes

---
Tags: matrix, stash
---


title: Template usage based on category

text:
# Question
Title: Template usage based on category
Is it possible to use particular template group based on a category of landing page? For an example product categorized as furniture will load template from furniture template group (index) instead of user will go to Pages -\> Templates and choose it from a drop down.

Thanks

# Answer
> 1 votes
I haven't used it myself, but Router looks to be what you need to use.

---
Tags: templates, categories
---


# Question
Title: Anyone know of a plugin to show Category count?
Basically want to find the number of entries per category in order to perform a conditional to show different content based on the entry count. Essentially:

if count = 2 then this if count is less than 2 then something else.

Native way would be preferred but any ideas?

# Answer
> 4 votes
I think GWcode Categories would be the easiest way to do this: http://gwcode.com/add-ons/gwcode-categories. It can also do a great number of other things with categories.

There's also an add-on just for counting category entries: http://devot-ee.com/add-ons/category-count

I actually use both on my site. I don't think there is a native way to do this without an add-on.

---
Tags: categories, conditionals, count
---


# Question
Title: Convert Custom Field Content to Lower Case with Dashes
I have a custom field with a person's name in it, and I need to convert it (in the template) to all lowercase with dashes instead of spaces so I can use it as an ID tag. Example:

`Suzie McRowdy` becomes `suzie-mcrowdy`

Is there an (ideally free) add-on that will take care of this for me?

# Answer
> 4 votes
If you need to do this from the template you could use a plugin like this one:

http://devot-ee.com/add-ons/create-url-title

If you need to do it directly to the DB please update us so we can give you that solution as well.

Note: CE String also has a custom method called url\_title which will do the same thing but, it's not a free add-on.

# Answer
> 2 votes
I did this with CE String:

```
<a href="{url}" class="icon-{exp:ce_str:ing url_title}{label}{/exp:ce_str:ing}">{label}</a>

```

You can see the docs here

The reason I like this method is CE String is super helpful across most site builds. It has so many useful features!

# Answer
> 1 votes
You could also use Low Replace (which is FREE!):

http://gotolow.com/addons/low-replace/docs#tags

I haven't used it for adjusting the `case` of outputted data but it is supported.

That should get you started!

---
Tags: add-on, custom-fields
---


title: Conditionals not Parsed in form

text:
# Question
Title: Conditionals not Parsed in form
I am creating a form via module, that I wish to use for both insert and update. After the insert user has the option of going back to edit the values previously input. The issue that I encounter is with the update.

This function decides if insert or update

```
public function form()
{
    session_start();
    $tagdata     = $this->EE->TMPL->tagdata;

    if(isset($_SESSION['id'])){
        $variables   = array();
        $variables[] = $_SESSION['tags'];

        return self::buildForm('updateForm', $tagdata, $variables);

    }

    return self::buildForm('addDonation', $tagdata);
}

```

While this function handles the actual building of the form

```
public function buildForm($method, $tagdata, $variables = FALSE)
{
    $hidden_fields = array(
        'ACT' =>  $this->EE->functions->fetch_action_id('Meal', $method)
    );

    if($variables != FALSE){

        $conditionals = $this->EE->TMPL->simple_conditionals($tagdata, $variables);
        $conditionals = $this->EE->TMPL->parse_variables_row($conditionals, $variables);

        print_r($conditionals);

        $content = $this->EE->TMPL->parse_globals($this->EE->TMPL->final_template);

    }

    //Build an array with the form data
    $form_data = array(
        "id"            => $this->EE->TMPL->form_id,
        "class"         => $this->EE->TMPL->form_class,
        'hidden_fields' => $hidden_fields
    );

    $form = $this->EE->functions->form_declaration($form_data) . $content . "</form>";

    return $form;
}

```

The output is currently `{if FirstName !=` and {FirstName} within the conditional is not being parsed.

Any help greatly appreciated!

# Answer
I think you're making this more complex than needed. This should suffice:

```
if($variables != FALSE)
{
    $content = $this->EE->TMPL->parse_globals(
        $this->EE->TMPL->parse_variables($tagdata, $variables)//preps then runs parse_variables_row()
    );
}

```
> 2 votes

---
Tags: conditionals, module, forms
---


# Question
Title: Upgrade to EE 2.7.3 login to CP via link not working any longer
On 2.5.5 I had a link like this on the client's product pages: http://cl.ly/image/2c3G3m1X0a3D

Very simple, if they are logged into the CP on another tab, they click the edit link and it opens this product's CP edit page in a new tab. The link looks like this: http://www.domain.com/admin/index.php?D=cp&C=content\_publish&M=entry\_form&channel\_id=12&entry\_id=7832

Worked great for years. Note also that the link is only shown if all these are true, so we know they are logged into a current CP session and have the right to see the link:

```
    $is_admin = TRUE;

    if($this->EE->session->userdata('group_id') != '1' AND $this->EE->session->userdata('group_id') != '6') {
        $is_admin = FALSE;
    }

    if($this->EE->session->userdata('access_cp') != 'y') {
        $is_admin = FALSE;
    }

    if($this->EE->session->userdata('admin_sess') != 1) {
        $is_admin = FALSE;
    }

```

I updated them to 2.7.3 and now those same links bring up just the CP login page. What has changed in the session/security model that would prevent this from working?

# Answer
> 1 votes
I believe what changed is that EE now defaults to requiring session IDs in the control panel URLs. (That's the S=e8a181fc77af1b35e47193c0e0b27a15 part you see.)

You can disable this at Admin -\> Security and Privacy -\> Security and Sessions, changing the Control Panel session type to Cookies Only.

Or, you can just add the session ID into your URLs, which is available in templates as `{cp_session_id}`

---
Tags: sessions, xss
---


title: Auto-synchronize an upload directory

text:
# Question
Title: Auto-synchronize an upload directory
Does anyone know a way to automatically synchronize a file directory? Possibly through a cron?

I need to have an image manipulation done to the member photo directory, and I don't see a way to do that automatically through the Members module.

Using EE 2.6.1

Thanks!

# Answer
> 2 votes
There's no built in way to do this. You'd need to build an add-on that triggers the manipulations, similar to how it's triggered when the images are uploaded through the control panel.

An easier way to handle this might be to do the resizing on the frontend using the CE Image plugin. The manipulations get generated when they are needed, so you don't need to worry about a cron job to process new images for you.

---
Tags: file-manager
---


# Question
Title: Freeform Pro : Where do I set the file size limit for a file upload field
I keep getting this error message:

The file you are attempting to upload is larger than the permitted size.

I can't find where I can set the limit in Freeform.

My PHP upload\_max\_filesize is set to 2M and the file I am trying to upload is less than 100K.

# Answer
> 1 votes
You may want to check a couple more php.ini settings.

`post_max_size` \- the maximum size for a post request including any files and any other text fields

`memory_limit` \- your memory limit also has to be large enough to hold the largest upload you will accept

And lastly, the upload location preferences for the location you've selected to use in Freeform has its own maximum file size setting. This can be found by editing the upload location in File Upload Preferences in the control panel.

---
Tags: solspace-freeform
---


# Question
Title: Filtering channel entries by more than one options
I need to find some solution to implement the filter for channel entries.I have a mock-up like you can see at screenshot.

User can select more than one options.

I tried to use Low Search plugin, and my first idea was to form url according to selected options. But I don't understand how can I do this. Especially as I know url must be encoded.

May be anyone can give me some idea about solution for my task?

# Answer
> 3 votes
With Low Search, you do not "form a URL", but rather you create a search form that you can submit, which will generate the URL for you. How you create the elements in your form depends on what types of filters you will need and how you set up your channels and fields.

For the alphabet, you can use the Field Search filter, but you'd have to hard-code the options yourself. Here I'm targetting the `title`, but you can target a custom field, too.

```
<select name="search:title[]" multiple>
    <option value="a">A</option>
    <option value="b">B</option>
    ...
</select>
<input type="hidden" name="starts_with" value="search:title">

```

For the style, *if* that is a custom field, also use the Field Search filter:

```
<select name="search:my_style_field[]" multiple>
    <option value="Style 1">Style 1</option>
    <option value="Style 2">Style 2</option>
    ...
</select>
<input type="hidden" name="exact" value="search:my_style_field">

```

For the country, *if* that is a category group, use the Categories filter:

```
<select name="category[]" multiple>
    {exp:channel:categories style="linear"}
    <option value="{category_id}">{category_name}</option>
    {/exp:channel:categories}
</select>
<input type="hidden" name="require_all" value="category">

```

And put all that inside the Form.

Be sure to read all the docs on Parameters, Filters, and Template Tags before checking out the example page.

---
Tags: low-search, filter
---


# Question
Title: File field inside Grid field inside Low Variable - File is not saved
So I've seen similar questions to this one, but they dealt with P&T addons Matrix & Assets. The problem I am experiencing is with EE Native Grid & File fields when they are placed inside of a Low Variable.

The file is uploaded correctly, it's not a permissions issue. I can see the file in the file manager and use it in other fields on the site.

My Low Variable is a Grid type, and it's got a column that takes a file upload. When I select the file, it shows the thumbnail, but as soon as I click 'save changes', it is gone.

When I logged the DB queries that ran when saving the field, it showed that the file field is getting set to NULL.

I'm running EE 2.7.3 and LV 2.4.0

# Answer
I just ran into this. All my grid fields were set as required, so leaving any field empty when saving removed the images. Adding data to all fields (including images) and it saved ok.
> 2 votes

# Answer
This will be fixed in the next version. In the meantime, if you make sure all columns are *not* required, you can avoid the issue, too.
> 2 votes

---
Tags: low-variables, grid
---


# Question
Title: Limiting channel entry results per channel
Assuming I have this:

```
{exp:channel:entries
    channel="news|tweets"
    disable="member_data|pagination|trackbacks|categories|category_fields"
    status="open"
}

    <h2>{title}</h2>

{/exp:channel:entries}

```

Is there any way I can limit the results of each channel? For example 5 from tweets, 10 from news. I'm assuming not...

# Answer
Your assumption is correct. You cannot limit to "X" number from EACH defined channel. You can limit to "X" number from the COMBINED defined channels using the limit="X" parameter.
> 2 votes

---
Tags: channel-entries
---


# Question
Title: Not outputting a heading if a search: within Grid has no results
We are using Grid to manage resources / and downloads on a site. We need to pull together resources from a number of different entries, based on segment. We use a search within Grid on a Select Dropdown to output the appropriate resource.

This is working as expected, but we cannot find a way to not output the `<h2>` and `<ul>` if the search: within Grid has no results. If we use {limit="1"} on {exp:channel\_entries} it won't work, as the entry it recalls may or may not have the appropriate resource in the Grid Select Dropdown.

Any help would be much appreciated, thanks.

```
<h2> Waste Management Group {segment_2}</h2>
<ul class="no-style-list resources">
{exp:channel:entries
    channel="groups"
    disable="categories|member_data|pagination|trackbacks"
    dynamic="no"
    status="open"
    cache="yes"
    refresh="30"
}
{group_resources search:resource_type="{segment_2}"}
    <li>
        <a class="{group_resources:resource_file}{extension}{/group_resources:resource_file} {group_resources:resource_type}" href="{group_resources:resource_link}{group_resources:resource_file}" target="_blank">
            {group_resources:resource_title} {group_resources:resource_file}</a>({exp:filesize_format dec="0"}{file_size}{/exp:filesize_format} {extension}){/group_resources:resource_file}

    </li>
{/group_resources}
{/exp:channel:entries}
</ul>

```

# Answer
You can use conditionals in the Grid loop to conditionally output the heading and `<ul>` tags:

```
{group_resources search:resource_type="{segment_2}"}
{if group_resources:count == 1}
<h2> Waste Management Group {segment_2}</h2>
<ul class="no-style-list resources">
{/if>
    <li>
        <a class="{group_resources:resource_file}{extension}{/group_resources:resource_file} {group_resources:resource_type}" href="{group_resources:resource_link}{group_resources:resource_file}" target="_blank">
            {group_resources:resource_title} {group_resources:resource_file}</a>({exp:filesize_format dec="0"}{file_size}{/exp:filesize_format} {extension}){/group_resources:resource_file}

    </li>
{if group_resources:count == group_resources:field_total_rows}
</ul>
{/if}
{/group_resources}

```
> 1 votes

---
Tags: grid
---


title: Stash List - Showing too many results

text:
# Question
Title: Stash List - Showing too many results
I have a news page that should either display 10 results regardless of category or 10 results based on the category information in the URL.

My code is checking to see if there is a category url in the URL and if so performs a query with the category id to limit results to that category otherwise falls back to performing a full query.

I've tested my logic and my conditional and EE queries are working as expected but when I output the Stash list it's displaying results for entries that are not in the category.

Do I need to have two different list names?

```
{if segment_2_category_id != ''}

        {exp:stash:set_list name="news_list" parse_tags="yes" parse_depth="2"}
            {exp:channel:entries channel="news" status="open|featured" orderby="date" sort="desc" limit="10" category="{segment_2_category_id}"}
                {stash:item_title}{title}{/stash:item_title}
                {stash:item_url}{url_title}{/stash:item_url}
                {stash:item_date}{entry_date format="%F %d, %Y "}{/stash:item_date}
                {stash:item_copy}{news_content}{/stash:item_copy}
                {stash:item_entry_id}{entry_id}{/stash:item_entry_id}
                {exp:stash:set_list:nested name="item_media" context="{entry_id}" parse_tags="yes"}
                    {news_videos_images}
                        {stash:item_image}{image}{/stash:item_image}
                        {stash:item_video}{video}{/stash:item_video}
                    {/news_videos_images}
                {/exp:stash:set_list:nested}
            {/exp:channel:entries}
        {/exp:stash:set_list}
    {if:else}

        {exp:stash:set_list name="news_list" parse_tags="yes" parse_depth="2"}
            {exp:channel:entries channel="news" status="open|featured" orderby="date" sort="desc" limit="10"}
                {stash:item_title}{title}{/stash:item_title}
                {stash:item_url}{url_title}{/stash:item_url}
                {stash:item_date}{entry_date format="%F %d, %Y "}{/stash:item_date}
                {stash:item_copy}{news_content}{/stash:item_copy}
                {stash:item_entry_id}{entry_id}{/stash:item_entry_id}
                {exp:stash:set_list:nested name="item_media" context="{entry_id}" parse_tags="yes"}
                    {news_videos_images}
                        {stash:item_image}{image}{/stash:item_image}
                        {stash:item_video}{video}{/stash:item_video}
                    {/news_videos_images}
                {/exp:stash:set_list:nested}
            {/exp:channel:entries}
        {/exp:stash:set_list}
    {/if}

```

# Answer
Probably parse order because ifelse makes it an advanced conditional which is parsed later. Try 2 single if statements and you should be set.

```
{if segment_2_category_id != ''}---{/if} {if segment_2_category_id == ''}---{/if}

```

For more on parse order check http://johndwells.com/blog/expressionengine-parse-order-advanced-conditionals-as-tag-parameters and @low has this excellent in-depth PDF on the issue loweblog.com/downloads/ee-parse-order.pdf
> 0 votes

---
Tags: stash
---


title: Query a NON EE table in database?

text:
# Question
Title: Query a NON EE table in database?
I have a HTML table where a user can subscribe.I send an ajax call when the user clicks the subscribe button and store it in a **non ee** table.Next time when the user comes on the same page,I want to show "you have ***subscribed*** instead of *subscribe*".PHP stage is input.

Because of some reasons,i cant store my data in exp\_members\_data.Since i am using a non ee table,

How can i query it to get the desired result.

Any solution? This is what I am doing.

```
{exp:query sql="SELECT screen_name, email, location FROM My_table WHERE user = 'subscribed'"}
        {screen_name}
        {email}
        {location}
{/exp:query}

```

# Answer
What you have will work fine. You can query any table in the database with the query module. You may, though, have issues with table prefixing. I'm not sure if the query module auto-prefixes tables or not, but in the past I've had issues with tables not named with exp\_, as EE tends to automatically add the prefix to queries.
> 1 votes

---
Tags: ee2, php, database, query, table
---


# Question
Title: Pixel & Tonic Field Pack 2.x :all_options and outputting when a checkbox is not selected
I have a template on a site being updated from EE 2.5.5 to EE 2.7.3 and during the update I've upgraded to the latest Field Pack 2.1.1.

My template includes use of a Field Pack - Checkboxes field and relies on the :all\_options capability available in Field Pack 1.

Consequently it now fails because I belatedly see there is no mention of `:all_options` in the docs for Field Pack 2!

http://docs.pixelandtonic.com/fieldpack/fieldtypes/checkboxes/tags.html

I'm using my checkbox series to output a table so it's critical I can output *something* for each option regardless of whether it is selected or not.

For example, here's some of the code I had that was working before…

```
{grade_ff:all_options}
  {if '{selected}' == ""}<td class="{option_name}"></td>
  {if:else}<td class="{option_name} y">Yes</td>{/if}
{/grade_ff:all_options}

```

So unless I've missed something I now have to have a line of code **for each of my options explicitly**

```
<td class="foo{if '{grade_ff:selected option="foo"}'} y">Yes{if:else}">{/if}</td>
<td class="bar{if '{grade_ff:selected option="bar"}'} y">Yes{if:else}">{/if}</td>

```

Is that right?

# Answer
The `:all_options` tag pair was actually removed removed two years ago, well before Field Pack 2.0 came out.

We removed it because EE doesn’t parse tags for fields that don’t have any data; it just removes them. And 99% of the time, people used the `:all_options` tag pair in cases where they would expect the options to appear regardless of whether a checkbox was checked or not, etc.. So it led to a lot of confusion when the options would randomly not appear for certain entries.
> 2 votes

---
Tags: pixelandtonic, field-pack, pt-checkboxes
---


# Question
Title: How do I reference a sub-category using {categories} tag pair?
I am using the {categories} tag pair to link entries to their relevant section, however, when I use the following code it does not display child categories.

```
{exp:channel:entries channel="section" category="{section_category_num}"}
<h1>{title}</h1>
{intro_text}
</div>
</article>

</section>

<section>
<article class="container">
{sub_section}
<div class="product eight columns alpha">
<div class="product_img">
<img src="{sub_section:product_photo}" title="" />
<div class="triangle"></div>
</div>
<div class="product_info">
<h4>{sub_section:categories limit="1"}<a href="/living-room/{category_url_title}">{sub_section:title}</a>{/sub_section:categories}</h4>
{sub_section:product_description}
</div>
</div>
{/sub_section}
</article>
</section>
{/exp:channel:entries}

```

Since this is a section page, what I want to be able to do is to reference the related entries child category url to link to the relevant sub section.

Any guidance will be appreciated.

Thanks.

P.S. I did attempt to use GWCode Categories but without success.

# Answer
It seems like you're most of the way there - you just need to make sure you prefix *everything* within your child entry loop.

```
{sub_section:categories limit="1"}
    {sub_section:category_id}
    {sub_section:category_url_title}
    {sub_section:category_name}
{/sub_section:categories}

```
> 0 votes

---
Tags: categories, relationships, gwcode-categories, child-categories
---


# Question
Title: Foreign Character showing Question Mark Diamonds
I have a problem, I have romainian character into the titles, but this code :

```
{exp:channel:entries channel="filme" orderby="title" sort="asc" dynamic="off" limit="1000"}
<?php
$letter = strtoupper(mb_substr('{title}', 0, 1));
if ($temp != $letter) {
    echo "<a href='$letter'>".$letter."</a>";
    $temp = $letter;
}
?>

{/exp:channel:entries}

```

Shows me on ș ț ă î something like these :� What should I do that the output of php to come well and make my sorting method work ? I want to build an Alphabet ..

# Answer
> 1 votes
Try next code:

```
{exp:channel:entries channel="filme" orderby="title" sort="asc" dynamic="off" limit="1000"}
<?php
mb_internal_encoding ("utf-8");
$letter = mb_strtoupper((mb_substr('{title}', 0, 1)));
if (!in_array($letter, $temp)) {
    echo "<a href='$letter'>".$letter."</a>";
    $temp[] = $letter;
}
?>

{/exp:channel:entries}

```

---
Tags: channel-entries, sort, title, low-alphabet
---


# Question
Title: Unable to load the following extension file: Better Workflow
I upgraded EE from v2.6.1 to v2.7.1. After upgrade, I am getting the following error:

> Unable to load the following extension file: ext.ep\_better\_workflow.php

Could anyone please help me.

Thanks,

# Answer
I resolved this issue by adding a config variable `third_party_path` like `$config['third_party_path'] = 'path/to/third_party';`
> 1 votes

---
Tags: better-workflow
---


# Question
Title: Unwanted paragraph tags added around checkboxes fieldtype in template
In my template, I have this code:

```
<dd>{categories backspace="2"}{category_name}, {/categories}{if habitat_category_other} ({habitat_category_other}){/if}</dd>

```

When rendered in the template, it is converted into:

```
<dd><p>Monarch Waystation, National Wildlife Federation, Other</p> (Monarchs Across Georgia)</dd>

```

which gives an odd line break.

How do I get rid of these automatically added paragraph tags? I don't see anything about this in the documentation for the categories tag pair.

Thanks!

**CORRECTION:**

The problem is actually occurring with a different line of code (not the categories tag -- although I will have to check that one now, too, because it's probably also malfunctioning). The offending line is:

```
<dd>{habitat_programs}{if habitat_program_other} ({habitat_program_other}){/if}</dd>

```

where "habitat\_programs" is a "Checkboxes" fieldtype. How does this change the answer if it's not the "Categories" tag pair?

# Answer
> 3 votes
Edit your field and ensure that **Default Text Formatting** is set to None, this should fix the issue.

# Answer
> 1 votes
Did you change your field type to a checkbox from something else?

Check the Default Text Formatting option in your field options. If it's set to something other than "none" change it to none. If it's on none, change it to something else, then back to none. In either case, a checkbox should show up to update entries with your new choice-- check it. And then click Update.

Everything should be reset to none now, and the tags should be gone.

# Answer
> -2 votes
You could try adding `style="linear"` to your `{categories}` tag.

Per this docs entry.

---
Tags: categories
---


# Question
Title: Find entries that have a specific file related to by Assets
I would like to be able to link to all entries that have a specific file included using P&T Assets. I have a page that displays the large version of an image which is called via this code:

```
{exp:assets:files file_id="{segment_2}"}
<img src="{url}" />
{/exp:assets:files}

```

So I know the file\_id (and any other info stored by Assets), is there a way I can search through the entries looking for that Assets file\_id?

# Answer
> 0 votes
I wasn't sure how to build the custom query, but I worked out this solution, but it's probably not the most efficient, but it works. I'm searching for the filename in the channel entries custom field instead of the file\_id. The original code now has an embed call to another template.

```
{exp:assets:files file_id="{segment_2}"}
<img src="{url}" />
{embed="includes/_related_entries" file="{filename}"}
{/exp:assets:files}

```

Then this is the embedded template (cf\_images is the Assets custom field):

```
{exp:channel:entries channel="yxz" disable="categories|member_data|pagination" search:cf_images="={embed:file}"}
<p><a href="{comment_url_title_auto_path}" title=""></a>{title}</p>
{/exp:channel:entries}

```

# Answer
> 0 votes
You would have to do a custom query against the exp\_assets\_selections table. Currently there's no other way.

---
Tags: assets
---


title: jQuery not working

text:
# Question
Title: jQuery not working
I'm new to EE.

My problem is that I can't load jQuery to my template.

I created a template in global/footer, then added just before the `</body>` tag the following:

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="{path='scripts/bootstrap'}"></script>
<script src="{path='scripts/brand'}"></script>

```

I also tried to link the file with `{theme_folder}`.

I searched everywhere (here, EE Forums...), seems like nobody has the same problem.

Maybe I just don't see it and it's really a simple error in my code.

Thanks in advance.

# Answer
> 2 votes
You don't mention if the text/code renders to the screen? If so you can debug in the browser inspector to find out the issue with paths or JS errors that may be preventing JQuery to run. So I'm assuming it's not rendering to the screen and based on the information you've provided, you have a "global" template group with a template called "footer".

Try accessing that directly on your URL /index.php/global/footer. That should render out that template.

If it's not, are you using external files or editing the template directly in EE interface (Database)?

If the template is an external file, are you sure the path is correct? Are any of your templates correctly appearing via external files?

If you can get the individual template to render, there's something wrong with your parent/root template and including the /global/footer template. Assuming you have a template group called "site" and a template called "index" and that this template group is set to your default, ensure you have:

```
{embed=global/footer}

```

...and you should be good to go.

On the assumption it is (and was) rendering the JavaScript include line to the browser output and it's the other lines you're struggling with, you're referencing the path tag, which means these are also templates. So you have a template group called "scripts" and templates called "bootstrap" and "brand". These are templates, not pointing to external files elsewhere in your build - is this intentional? You mentioned `{theme_folder}`, so I assume not.

Start by hard coding the URL: /themes/site\_themes//scripts/bootstrap.js (assuming that URL is correct for your server). If that works, convert to a variable (in your config.php file) which you can then utilise throughout your site and templates.

---
Tags: jquery
---


# Question
Title: Target the last relationship listed in a relationship field
I'm adding two div-wrappers around every 3 relationships. However, if the relationships count ends at 5, then I still need to add the ending div tags.

Here is the code -- where "IS\_LAST" is what I seem to need to target, How do I target the last relationship called into the loop?

```
 {models}
      {if models:count == "1 || 4 || 7"}
        <div class="item  active" >
               <div class="row">
      {/if}

      <!-- other code in here-->

      {if models:count == "1 || 4 || 7" OR  models:count == IS_LAST}
            </div>
            </div>
      {/if}
    {/models}

```

# Answer
> 1 votes
Try

```
 {models}
  {if models:count == "1 || 4 || 7"}
    <div class="item  active" >
           <div class="row">
  {/if}

  <!-- other code in here-->

  {if models:count == "1 || 4 || 7" OR  models:count == models:total_results}
        </div>
        </div>
  {/if}
{/models}

```

---
Tags: relationships
---


# Question
Title: absolute path URL in text field causing problems
i've got a text field that i'm using to include an optional url in entries which are used for homepage announcements. if a url is included, the homepage will link to that url. if not, it will link to the announcement itself:

```
<a href="{if announcement_redirect}{announcement_redirect}{if:else}{site_url}announcement/{entry_id}/{/if}">

```

works like a charm with local, relative urls (ie: /event/1234/). but when an absolute path is entered (ie: http://some.biz), it adds an anchor tag around the url and becomes `<a href="<a href="http://some.biz">http://some.biz</a>">` which is clearly not great.

the field's Default Text Formatting is set to None, and i even ran the "Update all existing channel entries with new formatting choice?" option to be sure of it.

i was running EE 2.6.1 and hoped an upgrade to 2.7.3 would fix it, but that hasn't had any effect either.

any ideas on how to nix the auto-HTML?

# Answer
Do you have 'Automatically turn URLs and email addresses into links?' set to 'no' in the channel's preferences?
> 2 votes

---
Tags: fields, text-formatting
---


# Question
Title: Taxes defaulting to a particular setting in CartThrob
We've just come across a strange issue in CartThrob (v2.3.5; EE 2.5.5) where the tax is calculating, but only somewhat.

We've got several different tax rates setup for two states: NY and CA. When using a NY zip code, the tax calculates correctly every time. For CA though, it **always** uses the first tax rate listed and ignores the others, regardless of zip code.

Here's a screenshot of that part of CartThrob: http://cl.ly/RpCc

With that set up, if I use 93657, whose tax rate is 8.975, it still gets calculated as 10% (the first CA tax rate). If I move the first listed CA tax rate of 10% to the bottom, and try to use 93657 again, it then defaults to 9.5% (the new first listed CA tax rate).

I have no idea what could be causing this issue. Any ideas?

# Answer
I remember this happening to us, try setting the state to blank instead of "California" so that just the zip codes are used in calculating the values.

We only used the state value if there was one flat rate for the entire state.
> 1 votes

---
Tags: cartthrob
---


# Question
Title: Force HTML emails for all Email Notification Templates
I have gone through and added HTML templates/emails for each of the template files in the CP Home -\> Email Notification Templates but not all of them are being sent as HTML. I don't know what else I need to change. The Admin notifications are coming through as HTML and some of the others are as well.

For example, the 'Forgotten Password Instructions' comes through as HTML, but the 'Mailing List Activation Instructions' will not.

I have changed the variables in the Email class to be 'html' for mailtype.

There is nothing different between the emails except for the variables.

Any ideas?

v2.5.5 - Build Date: 20121220

# Answer
Yes, while looking within the code I found that for some of these emails, the mailtype variable isn't being specified so for the HTML emails, you should put hack code:

```
$this->EE->email->mailtype = 'html';

```

with email code.
> 1 votes

# Answer
I figured out this awkward behaviour. You must set the mailtype BEFORE you set the message data. If you set it after the message it will have intrepreted the message as plaintext already.
> 1 votes

---
Tags: ee2, email, notification, html-email
---


# Question
Title: Can I upload a file and assign a category without going to File Manager?
I'd like to be able to be in an entry text area and make a link to a file I upload. Once uploaded, I see a button to "Edit File" but that only lets you define the meta fields, it doesn't contain the "Categories" tab, like what you'd see if you went to edit the file from File Manager.

Do I need to go to File Manager to specify categories, or is there an easy way to do it from the Upload File/Browse Server dialog that I don't know about?

Thanks for your time.

# Answer
> 1 votes
I don't see any options for deciding the categories for the files through that initial Upload File/Browse Server dialog. The File Manager is definitely your best bet! If it's really important to you, I'd put in a Feature Request!

---
Tags: file-uploads, categories
---


title: Cartthrob - Quick View/Quick Buy

text:
# Question
Title: Cartthrob - Quick View/Quick Buy
I'm needing to add a Quick View/Quick Buy feature to my client's products page. Basically when they click the Quick Buy button a modal/div containing product details and a Buy button should display. My client would rather have this than a separate product details page. Is there a recommended way to do this? I was thinking that I could pass the product id as a parameter in the call to open up the modal and have the product details functionality hidden in the modal div.

I've added the code below.

```
    <!-- product with call to modal -->
    {exp:channel:entries channel="assets" dynamic="no" sort="asc" category="22" limit="1" entry_id="23"}
 <ul>
      <li><strong>Date:</strong> {asset_date}</li>
      <li><strong>Price:</strong> {product_price}</li>
      <li><strong>Status: <span style="color: #5cb85c">Available</span></strong></li>
      <li class="reserve-button"><a data-toggle="modal" href="#styledModal" data-id="{entry_id}" class="btn btn-primary btn-sm">Reserve Asset</a></li>
  </ul>
  {/exp:channel:entries}

    <!-- product details modal content -->
    {exp:channel:entries channel="assets" category_id="22" limit="1"}
      {exp:cartthrob:add_to_cart_form id="add-cart" entry_id="{entry_id}" no_tax="{no_tax}" no_shipping = "{no_shipping}" return="checkout/view_cart"}
        <ul>
          <li><strong>Date:</strong> {asset_date}</li>
          <li><strong>Price:</strong> {product_price}</li>
          <li><strong>Status: <span style="color: #5cb85c">Available</span></strong></li>
          <li class="reserve-button"><button type="submit" class="btn btn-primary btn-sm">Reserve Asset</button></li>
        </ul>
      {/exp:cartthrob:add_to_cart_form}
     {/exp:channel:entries}

```

# Answer
I may be misunderstanding, but whether your div is modal or not isn't a any kind of deal really - you'd just have (another) add\_to\_cart form in it along with any details you need.
> 0 votes

---
Tags: cartthrob
---


# Question
Title: simple search not including some channels in results
For some reason news does not get included in the search results on this site, apparently it never did and people didn't notice until a year or so later.

This is the search code

```
{exp:search:simple_form
  channel="pages"
  result_page="Main/search_{embed:lang}"
  search_in="everywhere"
  channel="pages|jobs|slides|powerpoints|events_information|events|news_and_updates|awards|student_ambassadors"
  status="not closed"
  show_expired="yes"
  show_future_entries="yes"
  no_result_page="Main/search_no_results_{embed:lang}"}

    <input class="searchBox" type="text" name="keywords" id="keywords" value="" placeholder="Enter your keywords" size="18" maxlength="100" />
    <input class="searchLink" type="submit" value="search" class="submit" />

{/exp:search:simple_form}

```

Here is a screenshot of the channel names: **https://i.stack.imgur.com/5v9F2.png**

Any tips? I've been tasked with some revisions on a EE based site. This is the very last thing I need to fix from the very long list and its driving me bonkers, would appreciate any help! :D

# Answer
> 2 votes
Check to ensure the fields associated with the actual channel "news\_and\_updates" are searchable.

In the field settings there is an option: Is field searchable?

Make sure any that need to be, are.

---
Tags: simple-search, multiple-channels
---


# Question
Title: Paypal error: "Duplicate invoice ID supplied. Attempt with a new invoice ID"
I'm getting the error message, "The transaction was refused as a result of a duplicate invoice ID supplied. Attempt with a new invoice ID" when I try to process credit card payment through a PayPal Pro sandbox account.

How are invoice id generated in Exp-resso Store?

# Answer
Thanks for the replies! I figured out the problem; I had two store installations during development, one local and one live. I'd test the site locally which would send a transaction to paypal. Then, I'd upload the changes to the live site where my client would test the latest updates. Naturally the live site didn't increment the orders I place from my local computer - hence the duplicate invoice IDs' when orders were sent from the live site!
> 1 votes

# Answer
Store generates a new ID for each order (as Anna mentioned, this is based on the `id` column in the `exp_store_orders` table). Therefore it should not be possible for two orders to be created with the same ID, or payment to be submitted twice via Paypal.

What I assume happened is one of two things.

* At some point in the past you have had different shopping cart software linked to this PayPal account. This means that Store is trying to re-use IDs which have already been used by different software linked to your PayPal account.
* Alternatively, it's possible during testing you made a bunch of test orders, then deleted them and restarted Store's order numbering scheme, causing IDs to be reused. However, you didn't mention this in your question, so I'm going to assume this is not the case.

In any case, the easiest option is simply to disable PayPal's duplicate invoice ID check. Store already has its own checks to ensure orders are not paid twice, so the PayPal check is redundant. You can disable this check by logging into PayPal, under:

> My Account \> Profile \> My Selling Tools \> Credit Card Statement Name \> "Allow multiple payments per invoice ID"
> 2 votes

# Answer
I'm 99% sure the invoice number comes from the incremented "id" column in `exp_store_orders`. I wanted higher invoice numbers on a recent project so I manually changed the most recent test order "id" to 10000. That should work for you too.
> 0 votes

---
Tags: expresso-store, paypal
---


title: Segment parsing and embedded PHP errors

text:
# Question
Title: Segment parsing and embedded PHP errors
So basically we need to check the pattern of a segment and if it doesn't match our patterns we go on to start our entries loop with a category (via seg2cat).

if `{segment_2}` is a date, it's either formatted `YYYY-MM` or `YYYY-MM-DD`, otherwise it's a string.

```
<?php

    $this->EE =& get_instance();
    $seg2 = $this->EE->uri->segment(2);

    $date_pattern_half = '/^[0-9]{4}-(0[1-9]|1[0-2])$/';
    $date_pattern_full = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/';

    if( preg_match($date_pattern_full, $seg2) || preg_match($date_pattern_half, $seg2) ) {
?>
        {exp:low_events:entries channel="calendar" date="{segment_2}"}
<?php } else { ?>
        {exp:low_events:entries channel="calendar" category="{segment_2_category_id}"}
<?php } ?>

... do stuff with entries here ...

{/exp:low_events:entries}

```

The error we're getting back is:

**Parse error: syntax error, unexpected '}' in /server/domain/system/expressionengine/libraries/Functions.php(679) : eval()'d code on line 68**

for reference, the above function in Functions.php is:

```
/**
 * eval()
 *
 * Evaluates a string as PHP
 *
 * @access  public
 * @param   string
 * @return  mixed
 */
function evaluate($str)
{
    return eval('?'.'>'.$str.'<?php ');
}

```

As for the 'line 68' val it's just a closing `</ul>` tag.

---

I should also note that when we remove the opening loops (`{exp:low_events:entries}`) we don't get this error.

We've tried the alternative syntax `<?php else: ?>` etc but we get an `unexpected T_ELSE` instead of the one above.

# Answer
> 2 votes
It's probably caused by having PHP on Output, rather than Input, but you can avoid using PHP altogether. The way Low Events is set up, and the way Low Seg2Cat works, will allow you to set both parameters regardless of their format:

```
{exp:low_events:entries date="{segment_2}" category="{segment_2_category_id}"}
    ...
{/exp:low_events:entries}

```

If segment 2 is a date, it won't match a category, so the `{segment_2_category_id}` will be empty.

If segment 2 is a category, it will not match a date, so the `date` parameter will ignore that value and use today as the working date.

---
Tags: php, error, php-errors, low-seg2cat, low-events
---


# Question
Title: Low seg2cat & Stash: Error message when I use it in a conditional
I think I may be getting a parse order problem when I try and use Low's seg2cat variable in a conditional with Stash.

Here's my code:

```
{exp:stash:set name="pg_content_left"}

    {if segment_2_category_id != ''}

        {exp:stash:set_list name="news_list" parse_tags="yes" parse_depth="2"}
            {exp:channel:entries channel="news" status="open|featured" orderby="date" sort="desc" limit="10" category="{segment_2_category_id}"}
                {stash:item_title}{title}{/stash:item_title}
            {/exp:channel:entries}
        {/exp:stash:set_list}
    {/if}
 {/exp:stash:set}

```

Here's my error message:

```
A PHP Error was encountered
Message: Invalid EE Conditional Variable: {if segment_2_category_id != ''}

```

If I run the IF statement outside of stash:set it fails gracefully. I presume Stash is being parsed before low seg2cat variable is available. Anyone know how I can get around this?

Thanks.

# Answer
Try to setup Low seg2cat extension parameter **Set all segments** to **Yes**.
> 2 votes

---
Tags: stash, low-seg2cat
---


title: Store last 4 digits of credit card

text:
# Question
Title: Store last 4 digits of credit card
Is there a reason why Exp:resso Store 2 doesn't store the last four digits of the customers credit card number in the order details?

# Answer
The shopping cart and order management are completely separate to payment processing. Store is only concerned with the former and then making sure that an order needs to be marked as paid or not paid. Your chosen payment processor is responsible to taking, securing and processing the payment from your customers and then passing on a success or failure message to Store by way of the API response. In the vast majority of cases this is handled off-site on their servers so Store is never exposed to anything. With that in mind it's not actually possible to capture anything as Store never see's it.

You would still be in line with PCI DSS compliance to store the last 4 digits of the credit card number BUT guidelines strongly suggest that you encrypt this for added security. I certainly don't think any payment gateway would be sending that in a response from their API however so you're only option would be to then take responsibility from the payment processors' hands and take payments on-site meaning that you'd need to read through PCI DSS compliance guidelines and ensure you're secured to the hilt in regards to encrypted transactions, encrypted storage, physical security and every other directive. Expect a considerably high cost for doing this not to mention the burden of responsibility and potential auditing. You could then capture the details on site and send over to the payment processor, keeping the last 4 digits on record. I certainly wouldn't say it's worth it and certainly **wouldn't** recommend it.

Just be happy in the knowledge that ignorance is bliss and let someone else worry about the burden of online payment processing and PCI DSS compliance. It's what they take their cut for. :)
> 1 votes

---
Tags: expresso-store
---


# Question
Title: All upload destinations not visible in assets when opened from wygwam
I have several different upload destinations in my site, primarily one for images only, named "Images", and one for all kinds of files, named "Documents". I've chosen Assets to be the filemanager to use in Wygwam. Problem is, when I insert a new link in a wygwam field, and choose "Browse server", the only visible upload destination in the Assets popup is "Images".

There doesn't seem to be anywhere to select which upload destinations should be visible, and I'm pretty sure this has worked on other sites in the past. Anyone know what's going on?

I'm using EE 2.7.3, Wygwam 3.2.2 and Assets 2.2.2.

# Answer
> 1 votes
Go to Add-Ons \> Modules \> Wygwam \> \[your config\], and clear out the Upload Directory setting. Then Assets will show all of them.

---
Tags: assets, wygwam
---


title: Wygwam error after upgrade

text:
# Question
Title: Wygwam error after upgrade
I've upgraded a site to EE 2.7.3 and upgraded Wygwam to 3.2.2 , but now when I try and edit or publish a new entry, I get the error below:

Fatal error: Call to undefined method Wygwam\_helper::custom\_toolbar() in /var/www/vhosts/adaptservices.ie/httpdocs/system\_adapt/expressionengine/third\_party/\_wygwam/ft.wygwam.php on line 478

The module seems ok, I access it's settings, just not the channel entries where it's used.

The upgrade went fine offline, but the error appeared when I moved the site online.

Any ideas?

Thanks,

# Answer
That error is coming from a “\_wygwam” folder. When updating did you rename your old folder to that? Probably just need to delete it.
> 1 votes

---
Tags: pixelandtonic, wygwam
---