Forums / Setting Up Categories, Products, Attributes / Can I make "comments" a "required field" when making a purchase?

Can I make "comments" a "required field" when making a purchase?

Started by pixel1987 on 5 Jan 2015, 6:52 PM · Views: 2,388

Results 1 to 13 of 13
5 Jan 2015, 6:52 PM
#1
pixel1987 avatar

pixel1987

New Zenner

Join Date:
Dec 2014
Location:
uruguay
Posts:
65
Plugin Contributions:
0

Can I make "comments" a "required field" when making a purchase?

hi i want to know if a required field is possible when doing a purchase

Attachment 14839

thanks

7 Jan 2015, 4:51 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Can I make "comments" a "required field" when making a purchase?

Yes. If the attribute being filled in is a Text attribute, it can be forced to be required by selecting the required flag within the attributes controller... See the following FAQs:
http://www.zen-cart.com/content.php?99-how-do-i-add-attributes-to-my-products
and:
http://www.zen-cart.com/content.php?208-ok-when-i-set-a-attribute-to-an-item-like-a-color-that-must-be-specified-and-i-enable-the-required-button-on-the-attribute-it-is-letting-customers-add-items-to-the-cart-without-giving-a-required-attribute-what-could-be-causing-this (The first line applies only for this situation..)

There are other ways as well to do data validation after submitting, but the above should address your immediate concerns/issues.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Jan 2015, 5:05 PM
#3
pixel1987 avatar

pixel1987

New Zenner

Join Date:
Dec 2014
Location:
uruguay
Posts:
65
Plugin Contributions:
0

Re: Can I make "comments" a "required field" when making a purchase?

thanks for the reply, but served me because this is already created and donot where access it, is when the user is doing the buying asking these mandatory fields I want to add

7 Jan 2015, 5:10 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Can I make "comments" a "required field" when making a purchase?

Sorry, I guess I misunderstood the original request/expectation. Thank you for clarifying.

Although it probably is more preferred to put the attribute in the product itself, you could do validation in the header_php.php file that follows (or an observer) to kick back to the previous or designated page... Would check for the post data of the field to validate that it is not blank, and if it is blank to take the action necessary to 1) post a message about the need to enter the data and to return back (forward) to that page..

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Jan 2015, 5:44 PM
#5
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Can I make "comments" a "required field" when making a purchase?

If a dropdown of options would work (and it looks like it would) re-working this mod might be easier: http://www.zen-cart.com/downloads.php?do=file&id=90

7 Jan 2015, 6:04 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can I make "comments" a "required field" when making a purchase?

You could also customize the file:
/includes/modules/pages/checkout_configuration/header_php.php

and add the code in RED:

if (isset($_POST['payment'])) $_SESSION['payment'] = $_POST['payment'];
$_SESSION['comments'] = $_POST['comments'];

[B]// bof: force comment
if (trim($_SESSION['comments']) == '') {
  $messageStack->add_session('checkout_payment', 'Please enter order comments before proceeding.', 'error');
  zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
// eof: force comment
[/B]
//'checkout_payment_discounts'
//zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

Now, if they try to submit the order on the checkout_confirmation page without a comment, they will be returned to the checkout_payment and they will see a red message telling them to include a comment ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

7 Jan 2015, 6:05 PM
#7
pixel1987 avatar

pixel1987

New Zenner

Join Date:
Dec 2014
Location:
uruguay
Posts:
65
Plugin Contributions:
0

Re: Can I make "comments" a "required field" when making a purchase?

thank for the reply mc12345678 and stevesh; stevesh I have the version 1.53 that is a module and then lets me add a option value?
pd: products database with this module are removed?

mc12345678 I did not understand your answer

7 Jan 2015, 6:18 PM
#8
pixel1987 avatar

pixel1987

New Zenner

Join Date:
Dec 2014
Location:
uruguay
Posts:
65
Plugin Contributions:
0

Re: Can I make "comments" a "required field" when making a purchase?

it worked thanks RED, but is possible to make a option value in here?

7 Jan 2015, 6:42 PM
#9
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Can I make "comments" a "required field" when making a purchase?

It appeared from your image that you want the customer to choose from a number of companies the order would be shipped from. If that isn't correct, post again.

7 Jan 2015, 6:48 PM
#10
pixel1987 avatar

pixel1987

New Zenner

Join Date:
Dec 2014
Location:
uruguay
Posts:
65
Plugin Contributions:
0

Re: Can I make "comments" a "required field" when making a purchase?

that is correct as you say

7 Jan 2015, 7:12 PM
#11
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Can I make "comments" a "required field" when making a purchase?

pixel1987:

thank for the reply mc12345678 and stevesh; stevesh I have the version 1.53 that is a module and then lets me add a option value?
pd: products database with this module are removed?

mc12345678 I did not understand your answer

stevesh:

If a dropdown of options would work (and it looks like it would) re-working this mod might be easier: http://www.zen-cart.com/downloads.php?do=file&id=90

stevesh:

It appeared from your image that you want the customer to choose from a number of companies the order would be shipped from. If that isn't correct, post again.

pixel1987:

that is correct as you say

Maybe stevesh is in the process of responding, but as a sort of summary of the current discussion:
ZC 1.5.3 is installed, a plugin that offers a way to select from options and work with the result is available through the plugin identified. This feature appears to be what is most desired. The fact that the plugin though indicates that ZC 1.5.1 is the highest compatible version appears to be an issue of "concern". It could be that the plugin is still functional with ZC 1.5.3, might need some minor modification, or (and doubtful) some major modification to be compatible with ZC 1.5.3... One doesn't "know" until the installation is attempted or the plugin is identified as being 1.5.3 compatible...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Jan 2015, 7:14 PM
#12
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Can I make "comments" a "required field" when making a purchase?

Ajeh:

You could also customize the file:
/includes/modules/pages/checkout_configuration/header_php.php

and add the code in RED:

if (isset($_POST['payment'])) $_SESSION['payment'] = $_POST['payment'];
$_SESSION['comments'] = $_POST['comments'];

[B]// bof: force comment
if (trim($_SESSION['comments']) == '') {
$messageStack->add_session('checkout_payment', 'Please enter order comments before proceeding.', 'error');
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
// eof: force comment
[/B]

//'checkout_payment_discounts'
//zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

> 
> Now, if they try to submit the order on the checkout_confirmation page without a comment, they will be returned to the checkout_payment and they will see a red message telling them to include a comment ...

Thanks ajeh, that was what I was trying to consider although I didn't have the code available/in memory. :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Jan 2015, 7:17 PM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can I make "comments" a "required field" when making a purchase?

You are welcome ... I searched a few old threads and put something together that worked easily with v153/v154, and problem can be adapted for older, though upgrading is a good idea ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!