Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#856 2017-01-29 05:12:56

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 465
Website

Re: yab_shop (simple textpattern shop with paypal support)

yab_shop issue with txp version 4.6.2

After updating to txp version 4.6.2, yab_shop has stopped working on my site:

  • On the product page, the product options are not visible anymore, the button’s text is replaced by the text of the tag
  • On the cart page, all the text has been replaced by the text of the tags

I tried updating from yab_shop 8.0 to 8.1, but it still doesn’t work.

In the extensions tab, I checked shop_prefs and shop_lang

Both show a Yab Shop 0.8.1 - Install message and button. When I hit the button, I get the following error message:

Could not install language table, Could not install prefs table

It also gives this error when in testing mode:

A problem occurred while loading the plugin: yab_shop_admin -> Warning: mysql_num_rows() expects parameter 1 to be resource, object given on line 249

Please assist!

Last edited by Kjeld (2017-01-29 14:42:54)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#857 2017-01-29 22:31:57

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

Re: yab_shop (simple textpattern shop with paypal support)

I’ve hacked Kjeld’s copy of yab_shop for 4.6.x. Can’t say I’ve caught everything yet, but it seems to be holding up. For anyone who wants to update their copy of yab_shop 0.8.1 to work on Txp 4.6.2, here’s the diff you can apply:

diff --git a/yab_shop_admin.php b/yab_shop_admin.php
index 1a01734..fed100d 100644
--- a/yab_shop_admin.php
+++ b/yab_shop_admin.php
@@ -297,7 +297,7 @@ function yab_shop_update()
 function yab_shop_table_exist($tbl)
 {
 	$tbl = PFX.$tbl;
-	$r = mysql_num_rows(safe_query("SHOW TABLES LIKE '".$tbl."'"));
+	$r = mysqli_num_rows(safe_query("SHOW TABLES LIKE '".$tbl."'"));
 	if ($r)
 	{
 		return true;
@@ -790,29 +790,29 @@ function yab_shop_uninstall()
  */
 function yab_shop_install($table)
 {
-	global $txpcfg, $plugins_ver;
+	global $txpcfg, $plugins_ver, $DB;
 	$yab_shop_version = $plugins_ver['yab_shop_admin'];

-	$version = mysql_get_server_info();
+	$version = $DB->version;
 	$dbcharset = $txpcfg['dbcharset'];

-	if (intval($version[0]) >= 5 || preg_match('#^4\.(0\.[2-9]|(1[89]))|(1\.[2-9])#',$version))
+	if (version_compare($version, '5') >= 0 || preg_match('#^4\.(0\.[2-9]|(1[89]))|(1\.[2-9])#', $version))
 	{
 		$tabletype = " ENGINE=MyISAM ";
 	}
 	else
 	{
-	$tabletype = " TYPE=MyISAM ";
+		$tabletype = " TYPE=MyISAM ";
 	}

-	if (isset($dbcharset) && (intval($version[0]) >= 5 || preg_match('#^4\.[1-9]#',$version)))
+	if (isset($dbcharset) && (version_compare($version, '5') >= 0 || preg_match('#^4\.[1-9]#', $version)))
 	{
 		$tabletype .= " CHARACTER SET = $dbcharset ";
 		if (isset($dbcollate))
 		{
 			$tabletype .= " COLLATE $dbcollate ";
 		}
-		mysql_query("SET NAMES ".$dbcharset);
+		mysqli_query($DB->link, "SET NAMES ".$dbcharset);
 	}

 	$create_sql = array();
diff --git a/yab_shop_core.php b/yab_shop_core.php
index e8fc015..b58d37d 100644
--- a/yab_shop_core.php
+++ b/yab_shop_core.php
@@ -55,6 +55,22 @@ if (!defined('txpinterface'))
  * Version 3: http://www.gnu.org/licenses/gpl-3.0.html
  */

+if (class_exists('\Textpattern\Tag\Registry')) {
+    Txp::get('\Textpattern\Tag\Registry')
+        ->register('yab_shop_cart')
+        ->register('yab_shop_cart_items')
+        ->register('yab_shop_cart_subtotal')
+        ->register('yab_shop_cart_quantity')
+        ->register('yab_shop_cart_message')
+        ->register('yab_shop_cart_link')
+        ->register('yab_shop_checkout')
+        ->register('yab_shop_add')
+        ->register('yab_shop_price')
+        ->register('yab_shop_show_config')
+        ->register('yab_shop_custom_field')
+      ;
+}
+
 function yab_shop_cart($atts, $thing = null)
 {
 	extract(

Hope it helps someone.


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

Online

#858 2017-02-03 02:30:36

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 465
Website

Re: yab_shop (simple textpattern shop with paypal support)

Once again, many thanks for your help with this, Bloke!


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#859 2017-02-09 16:13:07

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)

Thanks Steff for your work, I really appreciate it.
I’ve updated the rest of the plugin to work with TXP 4.6 and PHP 7.1.

yab_shop_v0.8.2.tar.gz

Changes for 2017-02-09 – v0.8.2
  • bugfix: TXP v4.6-ready
  • bugifx: PHP v7.1-ready
  • bugfix: incorrectly formatted item amount when using paypal and promo code
  • bugfix: serbian dinar (RSD) know corrcetly shown as »din«

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

Offline

#860 2017-05-30 19:44:44

rewQ
New Member
Registered: 2011-03-04
Posts: 5

Re: yab_shop (simple textpattern shop with paypal support)

Hello! TXP 4.6.2, php 5.4. I’ve installed yab_shop, but i see error “user_error specified key was too long max key length is 1000 bytes “ Please, advise where is error?

User_Error “Specified key was too long; max key length is 1000 bytes”
in /home/users/9/—————-/domains/———/textpattern/lib/txplib_db.php at line 409.

adminErrorHandler()
textpattern/lib/txplib_db.php:409 trigger_error()
textpattern/lib/txplib_misc.php(1782) : eval()’d code:968 safe_query()
textpattern/lib/txplib_misc.php(1782) : eval()’d code:192 yab_shop_install()
textpattern/lib/txplib_misc.php(1782) : eval()’d code:89 yab_shop_first_install()
yab_shop_prefs()
textpattern/lib/txplib_misc.php:1895 call_user_func_array()
textpattern/index.php:214 callback_event(

Last edited by rewQ (2017-05-30 20:15:33)

Offline

#861 2017-07-23 06:47:54

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 465
Website

Re: yab_shop (simple textpattern shop with paypal support)

IMPORTANT : ITEMS NOT ADDED TO CART

trenc, thanks for the update of the plugin. I have been having serious trouble with this plugin, so just installed your update. Unfortunately this hasn’t solved the issues.

Site: MeijiShowa

ISSUE 1: Item Not Visible in Cart (issue occurs in Safari and Opera)
  1. Add an item to the cart, then view the check out (cart) page. The item displays.
  2. Continue shopping and add another item. Go to the cart page. The item does not display. (When the page is refreshed it does.)
ISSUE 2: Item Not Added to Cart at All (issue occurs in Google Chrome)
  1. Add an item to the cart and view the cart page. The item is not there. Refreshing does not help.
  2. Add another item and view the cart page. The new item is also not added to the cart.

These issues started after I updated to txp 4.6.2. Previously, yab_shop worked flawlessly.

A client also reported this issue. Since my site was updated this January, all orders have completely stopped… So this is a very serious problem for me.

Can you assist please?

Last edited by Kjeld (2017-07-29 07:44:30)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#862 2017-07-28 09:00:29

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 465
Website

Re: yab_shop (simple textpattern shop with paypal support)

Continuation of the above post.

I thought that perhaps one of the other plugins interfered. So I tried turning them off and on. But it had no effect on the problems I described in my previous post.

However, I did just notice that if I repeatedly refresh the page in Google Chrome, the items do eventually show in the cart. But I have to hit the refresh key many times. Like 20+…

So, it seems the cart is cached and not easily refreshed. That’s why the items added to the cart do not show up…

Incidentally, I also tested the yab_shop demo shop in all the browsers, and it doesn’t have this issue. So, the origins lie in my set-up, or perhaps —because I didn’t have this problem previously—the latest version of txp?

Any suggestions for fixing this?

Last edited by Kjeld (2017-07-28 09:29:29)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#863 2017-07-28 13:03:45

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 465
Website

Re: yab_shop (simple textpattern shop with paypal support)

FIXED

I figured out the problem. It was indeed a caching problem. And was caused by an admin setting. So, this means that other people may run into this very same issue.

This is how you solve it:

  1. Go to Admin : Preferences : Publish
  2. Set “Send ‘Last-Modified’ header?” to “No”

Last edited by Kjeld (2017-07-28 13:12:50)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#864 2017-07-28 13:24:05

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 465
Website

Re: yab_shop (simple textpattern shop with paypal support)

The above solution effectively switches off caching for all pages. This means an increase in bandwidth usage and load times.

It seems to me that ideally, the ‘Last-Modified’ header is automatically disabled for the cart page, regardless of the admin setting.

Is this possible?


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#865 2017-07-28 15:05:03

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

Re: yab_shop (simple textpattern shop with paypal support)

kjeld, I’ve once bookmarked this post from Ruud, where he sets a pref value explicitly only in a certain situation, filtered via conditional tags. I hope there’s an equivalent of setting last-modified that way.


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

Offline

#866 2017-07-28 19:12:07

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: yab_shop (simple textpattern shop with paypal support)

Can’t be done via a tag, because the last modified header is sent before the page is parsed.
It should be possible by hooking into this callback_event, and if the request_uri matches, change the last modified pref (for the current request, not in the database):
callback_event('pretext_end');

Offline

#867 2017-07-28 22:44:32

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 465
Website

Re: yab_shop (simple textpattern shop with paypal support)

ruud wrote #306476:

Can’t be done via a tag, because the last modified header is sent before the page is parsed.
It should be possible by hooking into this callback_event, and if the request_uri matches, change the last modified pref (for the current request, not in the database):
callback_event('pretext_end');

Thank you for the quick feedback, uli and ruud.

This explanation goes quite over my head, I am afraid. Do I understand correctly that you suggest creating a php function?

Unfortunately, I haven’t mastered php. What would the complete function look like and where would I need to add it?


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#868 2017-07-29 06:30:30

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: yab_shop (simple textpattern shop with paypal support)

Edit the yab_shop_core plugin and add this at the top:

register_callback('yab_shop_modified', 'pretext_end');

function yab_shop_modified() {
  global $prefs, $pretext;
  if (yab_shop_config('checkout_section_name') == $pretext['s']) {
    $prefs['send_lastmod'] = false;
  }
}

If it works, it should perhaps be added to the distributed plugin code.

Offline

#869 2017-07-29 07:39:39

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 465
Website

Re: yab_shop (simple textpattern shop with paypal support)

ruud wrote #306478:

Edit the plugin, at the top, add this at the top:

register_callback('pretext_end', 'yab_shop_modified');...

Something like that. Not tested. If it works, it should perhaps be added to the distributed plugin code.

Thank you very much, Ruud. I just tested this code by pasting it to the top of yab_shop_core. Unfortunately, when I turned the ‘Last-Modified’ header back on, the cart stopped displaying new additions. So this doesn’t work.

I wish I had studied php. I am afraid that except for discovering this issue, and testing and reporting, I am not of much help.

Last edited by Kjeld (2017-07-29 07:40:17)


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#870 2017-07-29 07:54:24

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: yab_shop (simple textpattern shop with paypal support)

If you send me a username/password, I’ll have a look.

Offline

Board footer

Powered by FluxBB