Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#316 2009-06-03 15:00:13

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,439
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

trenc

Thanks for the set-up guide and FAQ. Very useful.

Could add a wraptag and a class attribute on <txp:yab_shop_price />.

Brilliant, thanks. And thanks for considering my other random request about displaying the properties. Looking forward to what you come up with.

When a client logs in so call a function that create the cookies with the apropriate data from the ign-db-tables.

Aha! That makes sense. I’ll try that, thanks for the pointers.

I do think I jumped the gun a bit. I thought (could have sworn I read) somewhere that ign_pw_protect could be extended to store its own columns in its ign_user table. Thus I’d hoped to be able to add a few fields like street, promo discount, etc. But I can’t find any info on how to do this, so I’m writing a client-side admin screen that allows me to configure a new client. It stores all the data in smd_vars (remember that? Going to revisit it one day and make it work properly!)

could you test this and report whether and how it works?

Wow, great idea. Many thanks for the code.

Had a spot of bother getting it going. When you say “Place <txp:yab_special_promo /> after all <txp:yab_shop_cart /> in your pages” do you mean after every instance of <txp:yab_shop_cart /> or can I do it once at the end of the page/form?

I did edit the code, though, so I may have stuffed something up. Instead of using global $ign_data I changed it for $variable. What I have done is make a form called partner_promo that contains this:

<txp:smd_switch item='<txp:ign_user_info type="name" />'>

<txp:smd_case value="client1" />
<txp:smd_case value="client4" />
<txp:smd_case value="client5">
<txp:variable name="client_discount" value="10" />
<txp:variable name="client_discount_name" value="Premier" />
</txp:smd_case>

<txp:smd_case value="client2" />
<txp:smd_case value="client3">
<txp:variable name="client_discount" value="20" />
<txp:variable name="client_discount_name" value="Ultimate" />
</txp:smd_case>

</txp:smd_switch>

Using that I can apply one promo code to many clients by simply adding the client name to the Form. I might swap this info out to smd_vars as well at some point, this is just to test the concept.

So I then tried putting a call to <txp:yab_special_promo /> after each instance of <txp:yab_shop_cart />. Nothing happened. I checked the code and did some test output and found the yab_new_promo_prices() function was not being called. If I changed the function above to read if ($item['promocode'] == 1) then it works!

Except every time I refresh the checkout page it takes a further 10% off the price of all items… :-(

Is that because I’ve shafted something up or because I’ve put the special_promo on the checkout page after the <txp:yab_shop_cart output="none" />?

Many thanks for your work on this. If you want some more info off me just yell.

Last edited by Bloke (2009-06-03 15:13:05)


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

#317 2009-06-03 15:51:04

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Hi Stef,

When you say “Place <txp:yab_special_promo /> after all <txp:yab_shop_cart /> in your pages” do you mean after every instance of <txp:yab_shop_cart /> or can I do it once at the end of the page/form?

I think a single placing in the section(s), where the products are added should be enough.

Except every time I refresh the checkout page it takes a further 10% off the price of all items… :-(
Is that because I’ve shafted something up or because I’ve put the special_promo on the checkout page after the <txp:yab_shop_cart output=“none” />?

No, this is because you set if ($item['promocode'] == 1), it must be 0.
If it 1, so yab_new_promo_prices() will called every page reload and minimizes the price. But I don’t understand why it’s not called when it’s 0. It should be the default value of the $item['promocode'].

Ah, maybe you have to delete the previous session cookie!? If you have tested it before with the build in promo code support, so maybe the session is still present with previous values, where $item['promocode'] is already set to 1.

Last edited by trenc (2009-06-03 15:57:54)


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#318 2009-06-03 16:07:26

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,439
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

trenc wrote:

I think a single placing in the section(s), where the products are added should be enough…. maybe you have to delete the previous session cookie!?

Yep, those two steps fixed it. Brilliant stuff, thanks man!

EDIT: when I log out of the ign_ session, is there a function I can call in yab_shop to delete the session cookie? Or do I use the usual PHP methods? If I log out and log back in as another user, the previous cart contents is still set.

Last edited by Bloke (2009-06-03 16:10:18)


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

#319 2009-06-03 16:55:50

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,439
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Oh, and by way of passing on a tip, if anyone wants to take action depending if the cart contains any items, the solution is fairly simple:

<txp:variable name="cartqty" value='<txp:yab_shop_cart_quantity output="all" break="" label="" />' />

<txp:if_variable name="cartqty" value="0">
  // Nothing in the cart
<txp:else />
  // Something in the cart
</txp:if_variable>

Last edited by Bloke (2009-06-03 16:56:13)


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

#320 2009-06-04 08:49:29

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Bloke wrote:

EDIT: when I log out of the ign_ session, is there a function I can call in yab_shop to delete the session cookie? Or do I use the usual PHP methods? If I log out and log back in as another user, the previous cart contents is still set.

Hm, yes. This it’s a probem, ‘cause yab_shop works as non-login system and the session values are still available if an order will not be done (I know, it’s a real big issue on internet cafes and some multi-user terminals).

Normally the session will be depleted after a successful order. yab_shop do this with:

$cart->empty_cart();

So you can call this by an logout:

function smd_ign_clear_yab_shop_session()
{
	$cart =& $_SESSION['wfcart'];
	if (!is_object($cart))
	{
		$cart = new wfCart();
	}
	$cart->empty_cart();
}

But of course you can do this with a native PHP method. So it will be a a tabula rasa.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#321 2009-06-04 08:50:50

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Bloke wrote:

Oh, and by way of passing on a tip, if anyone wants to take action depending if the cart contains any items, the solution is fairly simple:

<txp:variable name="cartqty" value='<txp:yab_shop_cart_quantity output="all" break="" label="" />' />

<txp:if_variable name="cartqty" value="0">
  // Nothing in the cart
<txp:else />
  // Something in the cart
</txp:if_variable>

Lol, nice. Thanks Stef. Never thought of that.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#322 2009-06-05 10:04:17

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

New version v0.7.1:

  • bugfix: forms and select elements in article listings now have an unique id for XHTML-validity and form has an anchor
  • bugfix: replaced array_flip() with another method in yab_shop_field_names() to prevend some warnings and errors
  • bugfix: removed hardcoded withespace and doublepoint from label in <txp:yab_shop_cart_subtotal /> and <txp:yab_shop_cart_quantity /> for a flexible output
  • new feature: <txp:yab_shop_checkout /> now have the optional attribute ‘summary’ for html table summary (accessability)
  • new feature: added the attributes ‘wraptag’ and ‘class’ for <txp:yab_shop_price />
  • new feature: added new tag <txp:yab_shop_show_config /> for returning config values

Stef, the <txp:yab_shop_cart_items /> as container seems not as easy as thought. :(
I ought to use some kind of a template, because the parsing of the container have to loop (per every items in cart). But I have no enlightening moment this time how to catch it.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#323 2009-06-05 15:34:18

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,439
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

trenc

Brilliant stuff. And thanks for the tip about clearing the user data. I’ll do that on ign_logout() if I can.

No worries about the cart_items container. It was just a random idea. But related to my earlier question about the per-client percentages, do you think it would be possible for me to hack your per-client promo plugin to be able to detect which products are in the cart and apply different percentages per product? I was slightly mis-led (or I misunderstood, which is probably more likely!) and the situation is more complex than I thought:

  • Clients A and B might be on the Silver tier. This entitles them to 10% off Product1, 25% off Product2, 30% off Product3, 0% off Product4.
  • Client C might be on the Gold tier. This entitles them to 15% off Product1, 30% off Product2, 40% off Product3, 10% off Product4.
  • And so on…

If I could set up a similar system of $variables or smd_vars to hold this config data, is it possible to apply this kind of logic in the yab_special_promo() function? I don’t mind doing the heavy lifting in the code if you think it’s possible and could give me a few pointers about which variables I should be reading/altering?

Many thanks for your amazing support.


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

#324 2009-06-05 21:30:42

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Ah ok. I’ve updated the little mockup:

# Name: yab_special_promo v0.2 (compressed)
# Type: Client side plugin
# Client Specific Promocode Support (IGN-DATA)
# Author: Tommy Schmucker
# URL: http://www.yablo.de/
# Recommended load order: 5

# .....................................................................
# This is a plugin for Textpattern - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# .....................................................................

H4sIAAAAAAAAA+1V227jNhB9lr9iqgaRXcSWZDubjXwBsptgEaBIA3j3oVgEBi2NLCKUqIqU
vW6Qf++Qlpxs4/QL+iBpOHPmdkiOWBSOoicVjSO3YDm6ExWFF5G7Y6ulKjHmTCzLSubSGEi/
wUpxWZjVKHKDwdBIHyO3wg1vDUHkms+HyGW1zmRlY55H7leZ5ztYxFlex4+4VwctaFlX3GiG
pMm0LiPf3263A6pDyEGCvkWHkZugiite6ibXmOr+LDgWGham3JTHcG/qjWWCsKjLUlYaurdf
7vrXV1+vesaHSpFV0hQQuec2TuTqXYmNKmhrE5Ily2PgDEVpxMtzosGZZuH8WqICWYgdbGX1
CFuuM9AZQloLAZbOTJZQinrNi8HUJ49Ox5mW86nSlSzW82+KrTGa+s1yuqrAn3f+lDXErACF
2kabmr7mp7+OLidl26ZdTX1rAV4cki1jWaR8DVoCK3awYaJGkBUIZBsErmElWPE4gNt0L4GS
1ADEGcaPstZQUkE2aSE1AlsZnVkeElOT1BtZIeGqFGyHCXVWNo3dCxYfChZ6on+U0ZtjZTxj
WRd6dvpXLfVk/wb/dK0PLbFUYwUtT0yIA0nHotvGGW36TzEMLbKubE9qAAu2o61gMS/WxpRK
aVKkRA6F34OAItUigRUCFrJeZ69a+4Sg6gpf7UjbRpvPMkOutHUpHSLt80LjmnJQCiVz1Bml
PoNtxuMMtmj3OGYirgXTaA/PPt30l34f+vR8uvlyewf3v38zn8+LhVX2+4RQeieoFDq9M1fj
D+3HSrnzDkAWnkE2pGdkF2AqM5pWGFkBnsgKkLOKDmZ/JbWWeQTB4APmE2tJZaH7W+TrTEew
kiIh7fM+4tMLQPG/MYJwMMa8tQ+P2YfnL4DRO7knb93Cg5emifBO0S3InA/i5BV7N3fXx7hr
xpghzIyejyT/T+e7dDajz3Rp5/uQ5n5aF7GZxfDmZndPmNaq13nqOMRixWLd7TiOuCKlERxW
VWxnJcdrb4/nzObgBZ7R9s5sABJ7Hac3oYvHU+ietFCYzcDzeuD7NI9wY34AKaVtJtlhqrhu
x6EKnFd+JsGk4zxTxBM7KGancLJc3CwWt3/cffe2qVF6D5PW3p/T8F0ehl43pGIcGhXI6Op2
G8iaIDRuNdWhuj1gCk64xry3z24rN+vv3iGO92BaCAhhIW0uTPirZKp1M2+eeA9nYNMfgdOb
x8cczM4UuP0XquXjDA6FkcF76Nnwz4YfYuin7f3PIFZF5KZMKLS7vlctdV46s9b+G7xshA9h
QGezwVFLB1QfXnwJUKGuq6LRTTrPza3NE/szHg0jN1xdYHx5mSKGwXCFQXgZjC/GeBGMMQhG
mLiT538Awq8H4ugIAAA=

So now you can modify your form:

<txp:smd_switch item='<txp:ign_user_info type="name" />'>

<txp:smd_case value="client1" />
<txp:smd_case value="client4" />
<txp:smd_case value="client5">
<txp:variable name="client_discount" value='<txp:custom_field name="Premier_Discount" />' />
<txp:variable name="client_discount_name" value="Premier" />
</txp:smd_case>

<txp:smd_case value="client2" />
<txp:smd_case value="client3">
<txp:variable name="client_discount" value='<txp:custom_field name="Ultimate_Discount" />' />
<txp:variable name="client_discount_name" value="Ultimate" />
</txp:smd_case>

</txp:smd_switch>

<txp:yab_special_promo discount='<txp:variable name="client_discount"' />

This form you can place in your footer (in the sections, where a <txp:yab_shop_cart /> is placed too). The custom fields Premier_Discount and Ultimate_Discount you have to create, of course. So you can every single product/article assign with your tier-discounts (these should be float or integer) — hoping you have enough custom fields for your tiers.

But this will only work correctly (if it will work at all, I’ve doesn’t tested it) on individual articles. On article listings it will be a multi call of yab_special_promo.

Hope this is — roughly — what you have in mind.

Last edited by trenc (2009-06-05 21:38:12)


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#325 2009-06-07 19:15:56

kevinpotts
Member
From: Ghost Coast
Registered: 2004-12-07
Posts: 370

Re: yab_shop (simple textpattern shop with paypal support)

Trenc —

My site with your shopping cart is almost complete. Every feature upgrade has been awesome, and we’re now in the final testing phase. However, I am running into one significant bug that I can’t figure out. Everything goes through the PayPal process perfectly, and the purchaser receives their order confirmation e-mail, but I am not gettingreceiving any e-mails to the admin address for the orders. This is my set-up:

‘admin_mail’ => ‘graphicpush@gmail.com’,
‘order_affirmation_mail’ => ‘1’

Am I missing something? I also changed the Send “Last-Modified” header? to “no” but that did not help (not that I thought it would). Any ideas?

Also, another question. At the very end of the last PayPal screen, there is a button that says “Return to X” which goes to my thank you page. However, what is the variable that controls the name in that button’s label? Is the text after “Return to …” the name of the actual PayPal account holder?

Last edited by kevinpotts (2009-06-07 19:18:43)


Kevin
(graphicpush)

Offline

#326 2009-06-08 07:04:19

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Re: yab_shop (simple textpattern shop with paypal support)

Download links in the first post are broken :(

Offline

#327 2009-06-08 07:27:49

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: yab_shop (simple textpattern shop with paypal support)

FireFusion wrote:

Download links in the first post are broken :(

Untill trenc fixes it: http://www.yablo.de/files/yab_shop_v0.7.1.zip

Link directly to the file with out Textpattern’s clean urls.

Last edited by Gocom (2009-06-08 07:29:46)

Offline

#328 2009-06-08 09:23:19

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Hi Kevin,

My site with your shopping cart is almost complete. Every feature upgrade has been awesome, and we’re now in the final testing phase. However, I am running into one significant bug that I can’t figure out. Everything goes through the PayPal process perfectly, and the purchaser receives their order confirmation e-mail, but I am not gettingreceiving any e-mails to the admin address for the orders. This is my set-up:

‘admin_mail’ => ‘graphicpush@gmail.com’,
‘order_affirmation_mail’ => ‘1’

Am I missing something? I also changed the Send “Last-Modified” header? to “no” but that did not help (not that I thought it would). Any ideas?

no, you don’t miss anything. An email will not be sent if the payment methods are Google checkout or Paypal checkout for the following reasons: If an customer is on the third party payment page (say Paypal) and he decide not to finish the order so I have no feedback from Paypal this time about the cancel of the order. So it would be logical Paypal would manage the customer and admin order mails. But Paypal does not. :(

But when I will implement an IPN (Instant Payment Notification) yab_shop will have a Paypal feedback of the status of the current order (cancel, finished etc.) and then yab_shop is able to send the mails. But this implenetation will takes a while.

Also, another question. At the very end of the last PayPal screen, there is a button that says “Return to X” which goes to my thank you page. However, what is the variable that controls the name in that button’s label? Is the text after “Return to …” the name of the actual PayPal account holder?

I’m candid: I’ve no idea. But I think it’s the name of Paypal account (or it’s a business account the name of the company).


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#329 2009-06-08 09:28:15

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: yab_shop (simple textpattern shop with paypal support)

Download links in the first post are broken :(

Untill trenc fixes it: http://www.yablo.de/files/yab_shop_v0.7.1.zip

Link directly to the file with out Textpattern’s clean urls.

Yeah, thanks Jukka.
My hoster decided to move my hosting to another server with another structure so the paths has changed. :/
But I fixed it now. Maybe some other things are broken, but I can check this not before tomorrow.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#330 2009-06-08 13:44:00

kevinpotts
Member
From: Ghost Coast
Registered: 2004-12-07
Posts: 370

Re: yab_shop (simple textpattern shop with paypal support)

trenc wrote:

no, you don’t miss anything. An email will not be sent if the payment methods are Google checkout or Paypal checkout for the following reasons: If an customer is on the third party payment page (say Paypal) and he decide not to finish the order so I have no feedback from Paypal this time about the cancel of the order. So it would be logical Paypal would manage the customer and admin order mails. But Paypal does not. :(

OK, I understand. So is there another way the store manager could be notified of a purchase, or do they have to monitor PayPal manually? Seems kind of odd. Could you add a feature to fire off an e-mail to the admin saying something to the effect of “someone just clicked submit, better go check paypal to see if the purchase went through even though it might not have”. Because this particular store is just not going to be used that much, it is not realistic for PayPal to be constantly monitored.

But when I will implement an IPN (Instant Payment Notification) yab_shop will have a Paypal feedback of the status of the current order (cancel, finished etc.) and then yab_shop is able to send the mails. But this implenetation will takes a while.

This sounds perfect. How much money do you need? ;)


Kevin
(graphicpush)

Offline

Board footer

Powered by FluxBB