Post by Solan » Sat Mar 03, 2012 3:58 am

Hi

I would be happy to have the ability to let my customers upload an image and send it with their return form.

Is this possible with the code in this thread?
Or is it a bad idea cuz some images may have virus?

I want it to be safe.

Active Member

Posts

Joined
Sat Feb 19, 2011 7:34 pm

Post by SkipperTheEyechild » Sat Mar 03, 2012 8:27 am

@ solan

It should be possible with what you see in this form. You just need to make sure that you use the addAttachment() function when generating the e-mail (look above in the code). There shouldn't be any issue with viruses or anything like that, and even if somebody managed to send a virus in an image you would just need to make sure to use a decent anti-virus software (AVG, Norton, etc) that scans your incoming e-mail.

Follow the steps above for adding new fields to a form, and defining the variables in the Controller. However, take note that I had issues when receiving attachments using Mozilla Thunderbird, but was able to receive attachments with my Google account.

User avatar
New member

Posts

Joined
Fri Feb 24, 2012 8:58 am
Location - Montana

Post by visnetmedia » Mon Apr 02, 2012 12:10 pm

Hi I also wrote on philbydevil's download page - sorry to do it twice but am looking at the email sends to admin email and sender and redirects to link a pdf download? Also wondering if it would have an opportunity to add them to newsletter subscribers list if they wanted? big ask I know... thanks for the form tut...

Active Member

Posts

Joined
Fri Feb 12, 2010 7:17 am

Post by Calcite » Tue Apr 17, 2012 5:26 pm

Hopefully Skipper is around here soon.

The captcha register VQmod is not working on 1.5.2.1 and hopefully Skip will find a way to fix it ;)

Active Member

Posts

Joined
Fri Dec 30, 2011 3:21 am

Post by SkipperTheEyechild » Thu Apr 19, 2012 4:14 am

Hey guys, I've been neck-deep in some WordPress development lately and haven't really had a chance to look into this yet. I'll make a note and put it on my desk to hopefully get a chance to look at it this coming weekend (Apr 21-ish) if not sooner. I'll let you know.

Just as a general reminder for you though, the updates to OpenCart tend to break lots of things. So once you've deployed a website with a version of OpenCart I highly recommend not updating that site's OpenCart.... unless there is a HUGE security leak that is found in your chosen version and the update provides a fix.

Additionaly, @ visnetmedia -

If you can be a little more detailed about what you are experiencing and what your desired outcome is I may be able to help you find a solution. What you've got there is a little vague for me to understand.

User avatar
New member

Posts

Joined
Fri Feb 24, 2012 8:58 am
Location - Montana

Post by Calcite » Thu Apr 19, 2012 6:23 am

Hi SKE,

In my case I have not deployed the shop yet so I have been able to go to 1.5.2.2 without fear :)

If you can get the Captcha register Mod working with the new OC that will be great indeed.

In the meantime I have more work to get done which includes deciding on a payment gateway, something that appears to be a bit of a minefield :-\

Active Member

Posts

Joined
Fri Dec 30, 2011 3:21 am

Post by visnetmedia » Tue Apr 24, 2012 2:38 pm

Hi sorry for being vague was more of a request that the form can accomplish. I would love to automatic add the form submitter into the newsletter subscribe list like you can for register account form and once the form is submitted it goes to a page where they can download a pdf document.

thanks for your response... it is a wonderful form.

Active Member

Posts

Joined
Fri Feb 12, 2010 7:17 am

Post by SkipperTheEyechild » Fri Apr 27, 2012 4:48 am

@ Calcite

Wow! Amazing, but I found the problem and it is a single line that is throwing the entire thing! Seems that VQMod is rather picky about being able to successfully find the <search></search> query or it just dies on that script or passes it up.

At the veeeeerrrrrrrryyyyyyyy bottom of the XML file for this contact form in the second-to-last <operation> tag, you will see this:

Code: Select all

<div class="right"><a href="<?php echo $continue; ?>" class="button"><span><?php echo $button_continue; ?></span></a></div> 
What you need to do is remove those <span> and </span> tags from there so that it looks like this:

Code: Select all

<div class="right"><a href="<?php echo $continue; ?>" class="button"><?php echo $button_continue; ?></a></div>
I was reading the updated information for the latest version of OpenCart (1.5.2.1) and noticed that the author stated he had started treating buttons across the site as actual buttons and links rather than the old system of using CSS and jQuery to get buttons working. I'm guessing that the removed <span> tags are part of that change.

Anyhow. Solved! Tested it out on the latest version and that is all it takes.

* Additional note:

I noticed while testing the form that the website field is actually required despite not being marked as such. Just a heads-up for those of you out there using it. This can be fixed by editing the (around) line 145 in the XML file. Just do a search for "post['website']) < 3" without the double-quotes and it'll take you right there. You can just remove that entire thing if you don't actually want to require a website.
Last edited by SkipperTheEyechild on Sat Apr 28, 2012 12:18 am, edited 1 time in total.

User avatar
New member

Posts

Joined
Fri Feb 24, 2012 8:58 am
Location - Montana

Post by SkipperTheEyechild » Fri Apr 27, 2012 6:05 am

@ visnetmedia

There may be a problem with your request. The newsletter yes/no question is stored directly in the 'customer' table in the database. It is a boolean value, so 1 for yes, 0 for no.

The issue with adding this to a contact form is that it would have nowhere to be stored. The contact form would essentially have to register a user as well.

A way around this would be to do some extensive editing and require that you create a new database table simply to store e-mail addresses for the newsletter. While this isn't necessarily a bad idea, it would require changes to the registration form so that those e-mails are added to this new table, and then probably a bit of an overhaul to the newsletter system so that it gathers e-mail addresses from this new table.

In short, it might be easier to add a link at the bottom of the contact form suggesting that a user register with your site and get the newsletter.

==========

However, regarding your other question about redirecting the user to a place where they can download a file. You can easily redirect the user after a successful submission by searching for this line:

Code: Select all

$this->redirect($this->url->link('information/contact/success'));
Which appears around line 253 in the XML file. You just need to change that 'information/contact/success' to wherever you want to send the user. In this case you could send them directly to a file you have on the server, or even to a page that has a link to the file... which would likely be a better idea because then you don't completely remove the user's ability to navigate your site.

Say you have a custom information page that has the link to this file you would like them to download. Say that information page's id is 20. You would then alter the line to look like this:

Code: Select all

$this->redirect($this->url->link('information/information&information_id=20'));
Just remember that it IS hard-coded, so if you ever change that page you will need to edit that line to point to the new page ID.

User avatar
New member

Posts

Joined
Fri Feb 24, 2012 8:58 am
Location - Montana

Post by Calcite » Fri Apr 27, 2012 6:56 am

Hi STE,

Thanks for looking at the problem, but I can't find that line.

Are you talking about a different xml file?

I attached the one I have been using before upgrade.

I was the thread hijacker who asked for the Captcha on the register form ;)

Sorry if I confused the issue.

Attachments

Captcha on Registration page


Active Member

Posts

Joined
Fri Dec 30, 2011 3:21 am

Post by SkipperTheEyechild » Sat Apr 28, 2012 12:17 am

@ Calcite

Two things you will need to do with that file. First, on line 77 you're going to find YOURTHEME in all caps when you are calling the View File. You need to change that to your theme name. As an example, if you are using default make it look like this:

Code: Select all

<file name="catalog/view/theme/default/template/account/register.tpl">
Second, while the Captcha field will show, it isn't going to correctly validate. You can still submit the form even though it is there. To solve this you will need to add this:

Code: Select all

<operation>
            <search position="after"><![CDATA[
            if ($this->config->get('config_account_id')) {
            ]]></search>
            <add><![CDATA[
            if (!isset($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha']))    
            {

	             $this->error['captcha'] = $this->language->get('error_captcha');

	    }
            ]]></add>
        </operation>
Place it just before the </file> where you close out the Controller. So... around line 61 or so. Just make sure it goes in your Controller. Tested it on my local server and it seems to be validating and functioning correctly in OpenCart 1.5.2.1 now.

Hope that helps.

User avatar
New member

Posts

Joined
Fri Feb 24, 2012 8:58 am
Location - Montana

Post by Calcite » Sat Apr 28, 2012 3:46 am

STE

Worked like magic :dance:

Many, many thanks, for your time and ingenuity.

Active Member

Posts

Joined
Fri Dec 30, 2011 3:21 am

Post by visnetmedia » Mon Apr 30, 2012 2:24 pm

thank you that helped...

Active Member

Posts

Joined
Fri Feb 12, 2010 7:17 am

Post by Calcite » Tue May 08, 2012 1:07 am

STE

I now have an error.

When I go to register I see at the top of the page.

Notice: Undefined index: captcha in /Applications/MAMP/htdocs/vqmod/vqcache/vq2-catalog_controller_account_register.php on line 262

Looking in the vq2-catalog_controller_account_register.php cache and around the 262 line number is...

Code: Select all

	if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/register.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/account/register.tpl';
		} else {
			$this->template = 'default/template/account/register.tpl';
		}
I am guessing that the xmll needs to add the actual template name to the cache file but that's a wild guess as I haven't a clue really :ponder:



VQMOD Log reads...

---------- Date: 2012-05-07 17:54:52 ~ IP : 127.0.0.1 ----------
REQUEST URI : /index.php?route=account/register/zone&country_id=222&zone_id=
DOM UNABLE TO LOAD: /Applications/MAMP/htdocs/vqmod/xml/vqmod-catalog-captcha-registration-page.xml
----------------------------------------------------------------------

Any help greatly appreciated.

Active Member

Posts

Joined
Fri Dec 30, 2011 3:21 am

Post by SkipperTheEyechild » Wed May 09, 2012 1:47 am

@ Calcite

Might need you to put both your xml/vqmod-catalog-captcha-registration-page.xml file AND the cached version of that file up here for me to take a peek at. From the looks of it the error sounds like the captcha variable is not being properly defined somewhere.

Did this just begin happening recently? Was the form working just fine after the last fix? For that matter, have you made any changes to these files recently?

As for the template file, you wouldn't want to have it explicitly stated because the way it is written (as you have it above) will allow the file to work with any theme. Hard-coding it in there would restrict it to only using the specified theme's Registration Page. Anyhow, throw those files up here and I'll take a peek. I can't really figure what might be going on from here with my files as it isn't currently throwing an error.

User avatar
New member

Posts

Joined
Fri Feb 24, 2012 8:58 am
Location - Montana

Post by Calcite » Wed May 09, 2012 2:45 am

Hi STE,

I've attached both files (theme name is temporarily Mytheme)

As far as I remember I did not make any changes to either file after loading the new template. It did work in the old theme after your latest fix for 1.5.2.1.

I appreciate your help with this but please don't lose too much of your own time, as I expect there is plenty that needs done if your world is anything like mine!

Active Member

Posts

Joined
Fri Dec 30, 2011 3:21 am

Post by SkipperTheEyechild » Wed May 09, 2012 3:39 am

@ Calcite

Okay. Figured it out. It was a case of ambiguity. In the VQMod XML file you were searching for a line that actually appeared twice. So the check for the Captcha variable was being added both in the validate() function and in the index() function. As such, because it wasn't registered at that point it was freaking OpenCart out.

I updated the XML file so that it now looks for 'private function validate() {' and then places the captcha verification directly after that. This way it only shows up inside the validate() function.

Test it out, make sure it works for you. I did change the 'default' back to 'mytheme' so it shouldn't require any editing for you.

Attachments


User avatar
New member

Posts

Joined
Fri Feb 24, 2012 8:58 am
Location - Montana

Post by Calcite » Wed May 09, 2012 4:21 am

Works great!

Now I must have a look at it in more detail as there is a loophole for customers which will give me something to look at, as I think maybe the same VQmod could fix both pages.

Try this

Guest Checkout is disabled in OC.

Fill Shopping Cart

Go to Checkout, you must register.

Click Continue and the Checkout Register page appears with no Captcha.

This is not really a big deal as a customer if they have filled the cart will either abandon the sale or register.

Just thought I would mention it in case anyone doesn't know about it.

Active Member

Posts

Joined
Fri Dec 30, 2011 3:21 am

Post by SkipperTheEyechild » Wed May 09, 2012 4:50 am

Ah, yeah. That would require adding to the XML file and targeting a few additional files. The checkout process is pretty much entirely AJAX driven.

The view file you would be interested in (if you want to place the Captcha in the "Step 2: Account & Billing Details") is: /catalog/view/theme/YOURTHEME/template/checkout/register.tpl

The Controller file in this case then becomes: /catalog/controller/checkout/register.php

And then (this is speculation as I haven't attempted this yet) you may need to make some adjustments to the checkout.tpl file beginning at line 158 where the comment in the jQuery is "// Register". Also take note that when writing for the Controller file in this case it is no longer $this->data, rather it is $json['value']['value'].

A whole different kind of beast, but it should work mostly the same way.

User avatar
New member

Posts

Joined
Fri Feb 24, 2012 8:58 am
Location - Montana

Post by Calcite » Wed May 09, 2012 5:00 am

Thanks STE,

One for a rainy day methinks ;D

Active Member

Posts

Joined
Fri Dec 30, 2011 3:21 am
Who is online

Users browsing this forum: edkny and 121 guests