Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#793 2014-06-27 14:05:10

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,310

Re: yab_shop (simple textpattern shop with paypal support)

trenc wrote #194181:

Is your hosting safe_mod restricted? If so, then that’s the reason — and there is no really workaround without root access. You can only temporary change your files directory in textpattern to your certificate path, upload your files and change back and delete in your MySQL the file entries. But this is not tested and not recommended.

I tried that “changing paths” trick, uploaded via TXP etc, without success.

Btw. Is your hosting safe_mod restricted? If so, then that’s the reason — and there is no really workaround without root access.

According to phpinfo, safe_mode is off. If I ask the hoster to turn it on: Is there something I should be aware of, TXP things breaking elsewhere? See post below.

Last edited by uli (2014-06-27 15:21:37)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#794 2014-06-27 15:20:55

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,310

Re: yab_shop (simple textpattern shop with paypal support)

midmood wrote #200936:

It was a path problem
- you have to go to Admin > diagnostic in the textpattern backend,
- then copy the path stated under “$path_to_site:” and paste it in the plugin configguration file, modified to reflect the exact path to your certificates

Woohoo! Thanks!

Although the files could be viewed publicly–the URL composed from the admin settings–the necessary path had to be taken from diagnostics’ $path_to_site value, exactly as midmood wrote. Thanks again, midmood!

Thanks also to you, Stef, and Tommy, whom I totally didn’t mention initially while standing in front of a pile of problems. What a great plugin, what truckloads of work you put into it! Thank you!! :)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#795 2014-06-30 14:44:41

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,310

Re: yab_shop (simple textpattern shop with paypal support)

After a made payment I’m not redirected to the thank-you page but to the checkout section instead (empty cart). I’ve of course double checked whether I’ve correctly filled in the URL in the admin field checkout_thanks_site, and I found & filled in the setting for redirection in the Paypal sandbox (copied from TXP). This account is a business account, I add that because I found CeBe’s post with the tiny footnote. I’m at my wit’s end, any smallest clue is much appreciated.

Edit: I just got a verrry quick reply from the paypal guys: The ReturnURL transmitted to PP ends in /checkout/. I’ve checked my settings again, they’re correct. Could it be that the plugin sends the wrong parameter in some rare conditions?

Last edited by uli (2014-06-30 15:16:05)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#796 2014-06-30 15:31:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

uli wrote #281754:

Could it be that the plugin sends the wrong parameter in some rare conditions?

I’m not sure it’s so rare. In my modded version I had this problem and I think I traced it back to one or two issues. Not sure which it was, but the net effect was that changing both seemed to fix things. Assuming you’re using the official v0.81, try editing the code on line 584 of yab_shop_core from this:

if (gps('merchant_return_link') != '')

to:

if (gps('return') != '')

Next, find the yab_shop_build_paypal_encrypted_form function (line 1007), scroll down a bit to find the $parameters block around line 1055. Immediately before it, add this line:

$thanks = yab_shop_config('checkout_thanks_site');

Then you can change what I consider to be the real culprit in the $parameters block:

'return' => $section,

to:

'return' => $thanks,

I have a suspicion that it’s passing your checkout section as the return link, ignoring your thanks link. I also have reason to believe that PayPal throws back a return URL parameter instead of a merchant_return_link — perhaps in some previous version it used the merchant URL param and they changed it to just return. I’ve not been able to verify this from their API docs.

Anyway, see if that helps at all as a quick ‘n dirty hack.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#797 2014-06-30 22:16:47

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,310

Re: yab_shop (simple textpattern shop with paypal support)

Awesome, that worked! :) Thanks very much, Stef!


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#798 2014-07-01 14:29:42

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,310

Re: yab_shop (simple textpattern shop with paypal support)

I’m just testing the cart checkout form, intentionally making mistakes, and found that the dropdown for payment method changes its option back to the default one if the cart can’t be sent because of missing form field entries.

I tried hacking the plugin, including the #payment select into the cookie functions but that did’t work (would it work, if I did it right?). I also searched this topic but didn’t find a solution. Seems like I’m the first one to remark that issue.

What can I do to have the payment option be remembered across error checks?

Last edited by uli (2014-07-01 14:48:23)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#799 2014-07-01 14:40:40

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,310

Re: yab_shop (simple textpattern shop with paypal support)

BTW, here’s what I hacked together (the extended cookie functions):

function yab_shop_setCookies($first_name, $last_name, $street, $zip, $city, $state, $phone, $email, $payment)
{
	$cookietime = time() + (365*24*3600);
	ob_start();
	setcookie("yab_shop_firstname|r",	$first_name,	$cookietime, "/");
	setcookie("yab_shop_surname|r",	$last_name,	$cookietime, "/");
	setcookie("yab_shop_street|r",	$street,	$cookietime, "/");
	setcookie("yab_shop_postal|r",	$zip,	$cookietime, "/");
	setcookie("yab_shop_city|r",	$city,	$cookietime, "/");
	setcookie("yab_shop_state|r",	$state,	$cookietime, "/");
	setcookie("yab_shop_phone",	$phone,	$cookietime, "/");
	setcookie("yab_shop_email", $email, $cookietime, "/");
	setcookie("yab_shop_payment", $payment, $cookietime, "/");
	setcookie("yab_shop_last",	date("H:i d/m/Y"),$cookietime,"/");
	setcookie("yab_shop_remember", '1', $cookietime, "/");
}

function yab_shop_destroyCookies()
{
	$cookietime = time()-3600;
	ob_start();
	setcookie("yab_shop_firstname|r",	'', $cookietime, "/");
	setcookie("yab_shop_surname|r", '', $cookietime, "/");
	setcookie("yab_shop_street|r",	 '', $cookietime, "/");
	setcookie("yab_shop_postal|r",	 '', $cookietime, "/");
	setcookie("yab_shop_city|r",	 '', $cookietime, "/");
	setcookie("yab_shop_state|r",	 '', $cookietime, "/");
	setcookie("yab_shop_phone",	 '', $cookietime, "/");
	setcookie("yab_shop_email",	 '', $cookietime, "/");
	setcookie("yab_shop_payment",	 '', $cookietime, "/");
	setcookie("yab_shop_last",	'', $cookietime, "/");
	setcookie("yab_shop_remember", '0', $cookietime + (365*25*3600), "/");
}

function yab_remember($remember, $forget, $checkbox_type)
{
	if ($remember == 1 || $checkbox_type == 'forget' && $forget != 1)
	{
		yab_shop_setCookies(ps('firstname|r'), ps('surname|r'), ps('street|r'), ps('postal|r'), ps('city|r'), ps('state|r'), ps('phone'), ps('email'), ps('payment'));
	}
	else
	{
		yab_shop_destroyCookies();
	}
}

In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#800 2014-07-01 14:47:44

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

uli wrote #281810:

the dropdown for payment method changes its option back to the default one if the cart can’t be sent because of missing form field entries.

Bug. I missed that in my modded version because the site I tested it on only had a single payment method.

It’s not a super tricky fix, just involves adding $selected = ps('payment'); at the start of yab_shop_checkout_payment_methods() and then testing each case against that value to see if it needs to have the selected attribute added to the option tag.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#801 2014-07-01 14:54:01

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

uli wrote #281812:

BTW, here’s what I hacked together (the extended cookie functions):

Thanks. You can cross-reference that against the same functions in my version to see how I approached it.

I opted to pass in the cookies to set/get as an array so they could be read from the prefs. That fit my revised workflow, which allows you to choose which fields are mandatory. There didn’t seem much point forcing someone to enter their full set of details if they know they’re going to check out using PayPal, because PayPal use the customer’s PP address details as shipping destination, and disregards anything in the yab_shop form.

But for people who want to use PP as a credit card portal, they can choose to enter some or all of their details in the yab_shop form and anything mandatory that is missing will be prompted by PP when they try to pay.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#802 2014-07-01 15:11:29

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,310

Re: yab_shop (simple textpattern shop with paypal support)

Bloke wrote #281814:

and then testing each case against that value to see if it needs to have the selected attribute added to the option tag.

Unfortunately, I can’t make code of that advice: I can’t write one single straight line of code myself. My hacking is just duplicating something or imitating patterns I recognize.

Fortunately all these mentioned cases seem to follow the same pattern:

	if (yab_shop_config('payment_method_paypal') == '1')
	{
		$b++;
		$hidden_value .= yab_shop_lang('checkout_payment_paypal');
		$option .= tag(yab_shop_lang('checkout_payment_paypal'), 'option', ' value="'.yab_shop_lang('checkout_payment_paypal').'"');
	}

… so I only needed one example to proceed ;p


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#803 2014-07-01 15:34:22

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

uli wrote #281816:

so I only needed one example to proceed

Uhhh, with the aforementioned $selected line near the top of the function, off the top of my head something like this should work:

if (yab_shop_config('payment_method_paypal') == '1')
{
	$b++;
	$hidden_value .= yab_shop_lang('checkout_payment_paypal');
	$sel = ($selected === yab_shop_lang('checkout_payment_paypal')) ? ' selected="selected"' : '';
	$option .= tag(yab_shop_lang('checkout_payment_paypal'), 'option', ' value="'.yab_shop_lang('checkout_payment_paypal').'"' . $sel);
}

Rinse and repeat for each type. It’d probably be better if yab_shop_lang() was called once per iteration and stashed, instead of 3 times, but that’s not vital.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#804 2014-07-01 16:52:43

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,310

Re: yab_shop (simple textpattern shop with paypal support)

Off the top of your head was sufficient to fix the amnesia. Thanks, Stef, once again :)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB