Jobs!
Meetups by TopicMeetups by CityStart a MeetupWhat's Meetup
Home > All Topics > Internet & Technology > Web Design Meetups Everywhere > The Prescott Web Design Meetup Group
Organizer:

Join The Prescott Web Design Meetup Group!

We'll never share your email address without your permission. Already a Meetup member? Sign in.

Messages

Joomla/VirtueMart Users - vm hack

Message Board › Joomla/VirtueMart Users - vm hack

Mike Kreidel
user 2662246
Prescott Valley, AZ
8th Post

Ever wished you could remove all the unwanted "required fields" during the registration and checkout process in VirtueMart? Read on........

So what if you are running a Download Only online store and don't need to gather all the customer info like shipping address, phone, fax; all the extra bs virtuemart puts in? Because there is no admin option for any of this and that's really messed up. Anyhow,
I finally hacked VirtueMart enough to remove All but the necessary form fields for registration and purchase of products from a store. Got it all done with just 2 files. Best thing about this hack is once your logged in, you can add a product to your cart, hit checkout, hit confirm order and your off to PayPal in 3 clicks. Awesome!!!!

For my purpose I only need 3 required fields, first, last and email. It's easy enough to remove the form fields but what about the Javascript Validation and Popup and errors??? Well here ya go.

INSTRUCTIONS:
Open: /administrator/components/com_virtuemart /html/checkout_register_form.php

around line 35 look for this line:
$required_fields = Array( 'first_name', 'last_name', 'address_1', 'city', 'zip', 'country', 'phone_1' );
Remove unwanted names from this list. In my example I need first and last. So mine looks like this:
$required_fields = Array( 'first_name', 'last_name' );

Now, around line 60, look for this line:
$shopper_fields[uniqid('fieldset_be gin')] = $VM_LANG->_PHPSHOP_USER_FORM_BILLTO_LBL;
Below this line are all the shopper_fields. Simply comment out '//' All the lines that you don't need.

Here's what mine looks like now:
$shopper_fields[uniqid('fieldset_begin ')] = $VM_LANG->_PHPSHOP_USER_FORM_BILLTO_LBL;
//$shopper_fields['company'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_COMPANY_NAME;
//$shopper_fields['title'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_TITLE;
$shopper_fields['first_name'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_FIRST_NAME;
$shopper_fields['last_name'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_LAST_NAME;
//$shopper_fields['middle_name'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_MIDDLE_NAME;
//$shopper_fields['address_1'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_ADDRESS_1;
//$shopper_fields['address_2'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_ADDRESS_2;
//$shopper_fields['city'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_CITY;
//$shopper_fields['zip'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_ZIP;
//$shopper_fields['country'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_COUNTRY;
//if (CAN_SELECT_STATES == '1') {
//$shopper_fields['state'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_STATE;
//$required_fields[] = 'state';
//}
//$shopper_fields['phone_1'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PHONE;
//$shopper_fields['phone_2'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PHONE2;
//$shopper_fields['fax'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_FAX;
if (!$my->id && VM_SILENT_REGISTRATION == '1') {
$shopper_fields['email'] = _REGISTER_EMAIL;
$required_fields[] = 'email';
}

See I have commented out every line except first, last and email.
**Save the file with your new changes.


Now Open: /administrator/components/com_virtuemart /classes/ps_shopper.php
around line 33, look for these lines:
function validate_add(&$d) {
global $my, $perm;

$db = new ps_DB;

$provided_required = true;
$missing = "";

Start a new line right below $missing = ""; and add the following example:
####################### NEW CODE TO REMOVE VALIDATION FIELDS ##################################
$d['company'] = "no company";
$d['title'] = "no title";
$d['middle_name'] = "no middle name";
$d['address_1'] = "no address 1";
$d['address_2'] = "no address 2";
$d['city'] = "no city";
$d['zip'] = "no zip";
$d['country'] = "no country";
$d['state'] = "no state";
$d['phone_1'] = "no phone 1";
$d['phone_2'] = "no phone 2";
$d['fax'] = "no fax";
####################### End New Code ######################################## ##################

All you're doing here is assigning a "value" to the fields you are removing, thus fooling the javascript validation checker. So any fields you removed in the other file must be accounted for here as well. Follow the example above to change your file. The "values" can be anything you want, but all the ['fields'] have to be correctly referenced from the other file.

**Save the new file with your changes.
Upload new files and test it out!

Hope this helps someone out.

Mike

A former member
1st Post

Hi Mike

I found your article on the web when trying to solve a problem with adding a new Title to the list in Bill to Information on a VitueMart - the title (Miss) is missing? I need to add this... any ideas

Regards Terry

A former member
1st Post

Ever wished you could remove all the unwanted "required fields" during the registration and checkout process in VirtueMart? Read on........

**Save the new file with your changes.
Upload new files and test it out!


Mike - I found this on page 5 of google search. This edit you have is fantastic for me. I went into the first file you mention, and I don't have access to it. What is the file permission number so I can start?

Also, I'm a dummy, after I save the changes I still have to upload the file from where to where? or just click "upload file"? Sorry!

Thanks
Kathy

allrude
user 6644001
Hardenberg, NL
1st Post

works great, but do you have any tipps how to change te emails that VM sends to vendor and customer, they look strange with the fields still in them, also the registerform of vm still has some no longer needed fields in it !

if fixed for now but, i'm afraid that in my lack of knowledge, some thing else ...., so i'd love to see a good sollution.

Ruud

Powered by mvnForum