Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

(Shopp plugin) do not require address WordPress

I have searched the Shopp forums and have posted my own support thread, but the support there is sparse, and this is fairly urgent.

I'm trying to remove the need for the checkout to require/validate a billing & shipping address.

I have removed the code from the checkout.php file, and have added the below to the theme's functions.php file (as recommended by the plugin developer in an old forum post)

add_filter('shopp_billing_address_required','skip_validation');
add_filter('shopp_billing_postcode_required','skip_validation');
add_filter('shopp_billing_country_required','skip_validation');

function skip_validation() {
return true;
}


But I still get the following error: "You must enter a valid street address for your billing information."

Sorry if this is inappropriate for WP Questions - trying every possible resource!

Answers (3)

2011-05-11

Denzel Chia answers:

Hi,

Have you tried add_filter with priority?
maybe adding a later priority may help? as this will cause the filter to be added later and may overwrite what is added by the plugin.


add_filter('shopp_billing_address_required','skip_validation',90);
add_filter('shopp_billing_postcode_required','skip_validation',90);
add_filter('shopp_billing_country_required','skip_validation',90);

function skip_validation(){
return true;
}


if not try removing filter instead. change to the function name that is filtered in.

remove_filter('shopp_billing_address_required','function_to_remove',90);
remove_filter('shopp_billing_postcode_required','function_to_remove',90);
remove_filter('shopp_billing_country_required','function_to_remove',90);


Thanks.


Dan Davies comments:

Alas this makes no difference :(

2011-05-11

Kristin Falkner answers:

I think you would want skip validation to return false, not return true.

As explained best by one of the Shopp support leads:

<em>The %variable%_required filter should return false to prevent the error message, as you are filtering the result of empty($_POST['%variable%']).

A moment of consideration may be required for some of these filters, as to whether the true or false value is what you want as your filter's return value.

When in doubt, see Order::validform(), Order::validate(), and Order::isvalid() in shopp/core/model/Order.php for the original contexts of these filters.</em>


Dan Davies comments:

If I change it to return false, I get the following error on the confirm order page:

<blockquote>The shipping address information is incomplete. The order cannot be processed.</blockquote>


Kristin Falkner comments:

This is the part in the shopp/core/mode/Order.php that is generating that error:


// Check for shipped items but no Shipping information
$valid_shipping = true;
if (!empty($this->Cart->shipped)) {
if (empty($Shipping->address)) $valid_shipping = apply_filters('shopp_ordering_empty_shipping_address',false);
if (empty($Shipping->country)) $valid_shipping = apply_filters('shopp_ordering_empty_shipping_country',false);
if (empty($Shipping->postcode)) $valid_shipping = apply_filters('shopp_ordering_empty_shipping_postcode',false);
}
if (!$valid_shipping) {
$valid = false;
new ShoppError(__('The shipping address information is incomplete. The order can not be processed','Shopp'),'invalid_order'.$errors++,($report?SHOPP_TXN_ERR:SHOPP_DEBUG_ERR));
}

return $valid;
}

So essentially, if you're marking that the item(s) in question need to be shipped, then it is checking for the shipping info. So I'm not sure if (a) you're blocking the address information because the items do not in fact need to be shipped, in which case you just need to mark there is no shipping for the item in the product information or (b) the item is being shipped and you are collecting this information another way (through PayPal maybe?) in which case you would just need to apply the same type of filters to this above mentioned code.


Dan Davies comments:

That has taken it one step further - but now there is an error at PayPal:

<blockquote>Unable to process payment. Please contact the merchant as the postal address provided by the merchant is invalid, and the merchant has requested that your order must be delivered to that address.</blockquote>


Kristin Falkner comments:

What are you using as a gateway? PayPal Standard? And are you not wanting to collect an address because PayPal does or because the product does not need to be shipped? I don't know which of the above mentioned scenarios you went with, trying to add in filters or just selecting the product doesn't need to be shipped.


Dan Davies comments:

Sorry - using PayPal Standard as gateway, and not collecting an address because PayPal does, so simplifying the checkout process (!)


Kristin Falkner comments:

This is the area of info you'll want to look at, in the PayPalStandard.php payment gateway file:

/**
* form()
* Builds a hidden form to submit to PayPal when confirming the order for processing */
function form ($form) {
global $Shopp;
$Order = $this->Order;

$_ = array();

$_['cmd'] = "_cart";
$_['upload'] = 1;
$_['business'] = $this->settings['account'];
$_['invoice'] = mktime();
$_['custom'] = $Shopp->Shopping->session;

// Options
if ($this->settings['pdtverify'] == "on")
$_['return'] = shoppurl(array('rmtpay'=>'process'),'checkout',false);
else $_['return'] = shoppurl(false,'thanks');

$_['cancel_return'] = shoppurl(false,'cart');
$_['notify_url'] = shoppurl(array('_txnupdate'=>'PPS'),'checkout');
$_['rm'] = 1; // Return with no transaction data

// Pre-populate PayPal Checkout
$_['first_name'] = $Order->Customer->firstname;
$_['last_name'] = $Order->Customer->lastname;
$_['lc'] = $this->baseop['country'];
$_['bn'] = 'shopplugin.net[WPS]';

$AddressType = "Shipping";
// Disable shipping fields if no shipped items in cart
if (empty($Order->Cart->shipped)) {
$AddressType = "Billing";
$_['no_shipping'] = 1;
}

$_['address_override'] = 1;
$_['address1'] = $Order->{$AddressType}->address;
if (!empty($Order->{$AddressType}->xaddress))
$_['address2'] = $Order->{$AddressType}->xaddress;
$_['city'] = $Order->{$AddressType}->city;
$_['state'] = $Order->{$AddressType}->state;
$_['zip'] = $Order->{$AddressType}->postcode;
$_['country'] = $Order->{$AddressType}->country;
$_['night_phone_a'] = $Order->Customer->phone;

I don't have anymore time today to really look at it nor have I personally done this but things I would suggest trying (obviously with the ability to revert should any not work or cause a bigger problem): address_override to 0 to see if that works or possibly even removing all the address fields it's trying to pass in the form to PayPal. I've only used Authorize.net with Shopp. Maybe another expert can use this as a jumping off point should it not work but I think the key definitely is within the PaypalStandard.php gateway file.

2011-05-13

Just Me answers:

The easiest but probably not best way to go about this is to edit the checkout.php file. Set an initial value to the entry fields the system tries to validate.

Then hide the fields using CSS.