Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#796 2014-06-30 15:31:43
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.
Hire 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,316
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,316
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,316
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
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.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#801 2014-07-01 14:54:01
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.
Hire 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,316
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
selectedattribute 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
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.
Hire 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,316
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
#805 2014-07-01 18:06:58
- uli
- Moderator

- From: Cologne
- Registered: 2006-08-15
- Posts: 4,316
Re: yab_shop (simple textpattern shop with paypal support)
After submitting the cart to Paypal, for the user just nothing happens during several seconds and he might loose confidence re the functioning of the shop. There is, however, a notice displayed before the actual Paypal site opens, although probably unperceived as it appears below the remaing cart section.
It’d be great if future versions of the plugin would display the notice above the cart section: The bottom of the cart section can get below the fold too easily because the page jumps to the top after submitting. Especially if you turn on images for the cart, but also if the client ordered many articles or simply has a small screen.
BTW, that notice can be styled to be more striking via p#yabshoppaypalforward.yab-shop-message (I mention that as I found it impossible to capture the ID with Firebug).
Last edited by uli (2014-07-02 10:40:27)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#806 2014-07-14 14:56:52
- uli
- Moderator

- From: Cologne
- Registered: 2006-08-15
- Posts: 4,316
Re: yab_shop (simple textpattern shop with paypal support)
Has anybody found a solution for the annotation textarea of the cart page, i.e. what happens with any text already entered if the user chooses “Paypal” instead of “Invoice”?
Last edited by uli (2014-07-15 10:50:50)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#807 2014-07-15 11:00:34
- uli
- Moderator

- From: Cologne
- Registered: 2006-08-15
- Posts: 4,316
Re: yab_shop (simple textpattern shop with paypal support)
I’ve reworded my above question, it couldn’t be easily understood. Please give it a new try ;)
A word of warning: all the database fields for yab_shop_lang, regardless of their appearance as text input field or textarea, can only take 255 characters. Might lead to untended looks with texts being cut off or even juristic complications in case obligatory legal texts are concerned.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#808 2014-07-16 19:09:20
- uli
- Moderator

- From: Cologne
- Registered: 2006-08-15
- Posts: 4,316
Re: yab_shop (simple textpattern shop with paypal support)
I wrote #281820:
The bottom of the cart section can get below the fold too easily because the page jumps to the top after submitting. Especially if you turn on images for the cart, but also if the client ordered many articles or simply has a small screen.
I found the reason for the described baviour: The page tries to skip to #yab-shop-checkout-anchor but there simply is no element with that ID on the page. I think I could fix this by replacing the ID, at least it seems(!) to work but, please, Stef and Tommy, have a look at what I propose, whether it might impose problems I don’t yet perceive. Thanks!
Line 1260, before:
),'form', ' method="post" action="'.pagelinkurl(array('s' => yab_shop_config('checkout_section_name'))).'#yab-shop-checkout-anchor" id="yab-checkout-form"'
After:
),'form', ' method="post" action="'.pagelinkurl(array('s' => yab_shop_config('checkout_section_name'))).'#yabshoppaypalforward" id="yab-checkout-form"'
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#809 2014-07-16 20:14:51
- uli
- Moderator

- From: Cologne
- Registered: 2006-08-15
- Posts: 4,316
Re: yab_shop (simple textpattern shop with paypal support)
Found the first problem myself: On form submit check, the page doesn’t skip up anymore to the ID I replaced, the one that holds the issues the form is having. Actually there needed to be one more interrogation done by the plugin at which state the checkout process currently is, in order to use the appropriate ID as URL hash. I’m running out of ideas on how to fix that myself, that’s way beyond my horizon.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#810 2014-08-06 22:53:53
Re: yab_shop (simple textpattern shop with paypal support)
Hi,
I have this error on Paypal using the promocode with Yab_Shop 0.8.1 :
The link you have used to enter the PayPal system contains an incorrectly formatted item amount.
In my case, this fix seems to work; and this one does not.
But I also found something between these two which works:
(I don’t know if it’s a better solution… but it works and it could maybe help Trenc or Bloke.)
Replace
return $price;
to:
return number_format($price,2);
I also noticed that the phone number from my checkout form does not appear on the Paypal payment page; the field is empty.
Is there a way to send it nicely? Thx!
Last edited by NicolasGraph (2014-08-06 23:16:12)
Offline