Forums / All Other Contributions/Addons / MultiSite Module Support Thread

MultiSite Module Support Thread

Started by gerome on 23 Apr 2007, 10:24 AM · Views: 581,870

Results 481 to 500 of 2,247
26 Jun 2008, 7:40 PM
#481
jvoce avatar

jvoce

New Zenner

Join Date:
Jul 2006
Location:
Toronto, ON
Posts:
87
Plugin Contributions:
0

MultiSite Module Support Thread

First thank you cablesimple for leading me in the right direction.

I currently have
/httpdocs/includes/modules/pages/customers_authorization/header_php.php

Set up to send my regular customers back to the public site by using:

if ($_SESSION['customers_authorization'] != '0') {
  zen_redirect('http://store1.salvationarmy.ca' ."?zenid=". zen_session_id());

}

I've also used similar variations to update various files. The two sites are really begenning to look like one.

However, I want to follow this idea through more. In the file mentioned above I would like it to send a customer with products in their shopping cart to:

http://store1.salvationarmy.ca/index.php?main_page=shopping_cart

I'm not sure what sql inquiry I would have to add for this. I've been trying to take fields from the login header, but as of yet to no avail.

Any ideas?

26 Jun 2008, 8:03 PM
#482
cablesimple avatar

cablesimple

New Zenner

Join Date:
May 2007
Posts:
99
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Hey jvoce,
If I'm following you, you just want to check and see if they have products in their cart, and if they do then send them to the shopping cart page instead of the homepage.

this will get you that info:

if (count($_SESSION['cart']->contents) > 0)
{
    // Products in cart
}
else 
{
    // No products in cart
}
26 Jun 2008, 8:39 PM
#483
jvoce avatar

jvoce

New Zenner

Join Date:
Jul 2006
Location:
Toronto, ON
Posts:
87
Plugin Contributions:
0

Re: MultiSite Module Support Thread

As it stands right now my file:
/httpdocs/includes/modules/pages/customers_authorization/header_php.php

Reads this:

<?php
/**
 * Customer Authorization 
 *
 * @package page
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: header_php.php 2974 2006-02-05 04:53:19Z birdbrain $
 */


$sql = "SELECT customers_authorization 
        FROM " . TABLE_CUSTOMERS . " 
        WHERE customers_id = :customersID";

$sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
$check_customer = $db->Execute($sql);

$_SESSION['customers_authorization'] = $check_customer->fields['customers_authorization'];

if ($_SESSION['customers_authorization'] != '1') {
  zen_redirect('http://store1.salvationarmy.ca' ."?zenid=". zen_session_id());

}

if ($_SESSION['customers_authorization'] != '0') {
  zen_redirect('http://store1.salvationarmy.ca' ."?zenid=". zen_session_id());

}

require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
$breadcrumb->add(NAVBAR_TITLE);

if (CUSTOMERS_AUTHORIZATION_COLUMN_RIGHT_OFF == 'true') $flag_disable_right = true;
if (CUSTOMERS_AUTHORIZATION_COLUMN_LEFT_OFF == 'true') $flag_disable_left = true;
if (CUSTOMERS_AUTHORIZATION_FOOTER_OFF == 'true') $flag_disable_footer = true;
if (CUSTOMERS_AUTHORIZATION_HEADER_OFF == 'true') $flag_disable_header = true;

?>

I've changed it to the following:

<?php
/**
 * Customer Authorization 
 *
 * @package page
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: header_php.php 2974 2006-02-05 04:53:19Z birdbrain $
 */


$sql = "SELECT customers_authorization 
        FROM " . TABLE_CUSTOMERS . " 
        WHERE customers_id = :customersID";

$sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
$check_customer = $db->Execute($sql);

$_SESSION['customers_authorization'] = $check_customer->fields['customers_authorization'];

if (count($_SESSION['cart']->contents) > 0) {
	//Products in cart
	zen_redirect('http://store1.salvationarmy.ca/index.php?main_page=shopping_cart' ."?zenid=". zen_session_id());
} else {
	//No Products in cart
	zen_redirect('http://store1.salvationarmy.ca' ."?zenid=". zen_session_id());
}

require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
$breadcrumb->add(NAVBAR_TITLE);

if (CUSTOMERS_AUTHORIZATION_COLUMN_RIGHT_OFF == 'true') $flag_disable_right = true;
if (CUSTOMERS_AUTHORIZATION_COLUMN_LEFT_OFF == 'true') $flag_disable_left = true;
if (CUSTOMERS_AUTHORIZATION_FOOTER_OFF == 'true') $flag_disable_footer = true;
if (CUSTOMERS_AUTHORIZATION_HEADER_OFF == 'true') $flag_disable_header = true;

?>

I'm sorry , this is probably really simple, and I'm just not getting it.

26 Jun 2008, 9:01 PM
#484
cablesimple avatar

cablesimple

New Zenner

Join Date:
May 2007
Posts:
99
Plugin Contributions:
0

Re: MultiSite Module Support Thread

jvoce,
To be honest, I'm not quite sure what your doing with the customers_authorization code, however your redirection problem should be resolved by replacing your second "?" with a "&"

from this:

zen_redirect('http://store1.salvationarmy.ca/index.php?main_page=shopping_cart' ."?zenid=". zen_session_id());
```to this:

zen_redirect('http://store1.salvationarmy.ca/index.php?main_page=shopping_cart' ."&zenid=". zen_session_id());

26 Jun 2008, 10:15 PM
#485
jvoce avatar

jvoce

New Zenner

Join Date:
Jul 2006
Location:
Toronto, ON
Posts:
87
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Thanks alot cablesimple!

It was a long day, and I was really losing my focus. Thank fully I'm at home, and now with it working I can go off and BBQ without any worries.

Again, much thanks, it is really appreciated.

3 Jul 2008, 1:35 PM
#486
m4tty avatar

m4tty

New Zenner

Join Date:
Jun 2008
Posts:
18
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Hi

I'm have installed this mod but am having a problem with the categories. I am using it on a test server and so my url currently is https://www.example.com with the main index page being https://www.example.com/store/index.php.

I have installed the mod and can see the index page with my template but when I go into the multisite tools and try and assign categories to https://www.example.com, it tells me it has done it but this is not reflected on the site.

Any ideas of any basic mistakes I may have made which causes this problem?

3 Jul 2008, 1:41 PM
#487
m4tty avatar

m4tty

New Zenner

Join Date:
Jun 2008
Posts:
18
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Ignore me I was just being stupid :frusty:

9 Jul 2008, 12:57 AM
#488
makenoiz avatar

makenoiz

Zen Follower

Join Date:
Mar 2006
Posts:
284
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Anyone have Multisite and Authorizenet working together? I thought that I had it set up right but There does not seem to be any communication to Authorize net. no Errors, my transactions are not showing up in my authorizenet account. Tests dont show any errors. No errors when i deliberately set the API code and key wrong.

I always just get the zen cart confirmation page and nothing else.

Any help would be appreciated.

makenoiz

22 stores and counting! Ive been zenned.

17 Jul 2008, 12:36 AM
#489
hipctech avatar

hipctech

Totally Zenned

Join Date:
Oct 2004
Location:
Surrey, BC, Canada
Posts:
1,466
Plugin Contributions:
1

Re: MultiSite Module Support Thread

Hello there,
I am thankful to Jesus Christ for this mod. We at https://www.amazingdiscoveries.org have just started to use it for many sites and it works quite well now.
We did come over one problem, and that is with linked products. The cat_filter() function searches for products matching the SITE_NAME in the description where the id of that category is the products master_category_id. If I confused you, don't worry. It will be easy when you'll see the code. The thing is that if I had a category that only had linked products then those products would not be showed in the extra site.
I had to make a few changes to the function so I'll just submit it and I hope that the author will make the changes for the next release. The changes occurred is where you see the RIGHT JOIN in the SQL.

Starting on line 34 of the cat_filter.php file:

		} elseif($sql == "select products_id from " . TABLE_FEATURED . " where status= 1 limit 1") {
		// Special Query for the categories sideboxe/Featured Products
			$sql = "SELECT f.products_id FROM " . TABLE_FEATURED . " f
			INNER JOIN ".TABLE_PRODUCTS." p ON (f.products_id=p.products_id)
			INNER JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
			ON (cd.language_id=".$_SESSION['languages_id']."
			AND cd.categories_description LIKE '%-".SITE_NAME."-%')
			RIGHT JOIN zc_products_to_categories p2c ON (p2c.categories_id = cd.categories_id AND f.products_id = p2c.products_id)
			WHERE status=1 limit 1";
		} elseif($sql == "select s.products_id from " . TABLE_SPECIALS . " s where s.status= 1 limit 1") {
		// Special Query for the categories sideboxe/Special Products
			$sql = "SELECT s.products_id FROM " . TABLE_SPECIALS . " s
			INNER JOIN ".TABLE_PRODUCTS." p ON (s.products_id=p.products_id)
			INNER JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
			ON (cd.language_id=".$_SESSION['languages_id']."
			AND cd.categories_description LIKE '%-".SITE_NAME."-%')
			RIGHT JOIN zc_products_to_categories p2c ON (p2c.categories_id = cd.categories_id AND s.products_id = p2c.products_id)
			WHERE status=1 limit 1";
		} else { // Query with categories but not descriptions
			$str_pos_cats = strpos($sql_lower,TABLE_CATEGORIES . ' c');
			if($str_pos_cats!==false&&$str_pos_cats<$str_pos_where) {
				$add_pos = $str_pos_products + strlen(TABLE_CATEGORIES . ' c');
				$str_pos_coma = strpos($sql_lower,',',$add_pos);
				if($str_pos_coma!==false) {
					$add_pos = $str_pos_coma;
				} 
				if(($str_pos_where!==false)&&(($str_pos_coma===false)||($str_pos_where<$str_pos_coma))) {
					$add_pos = $str_pos_where;
				}
				$sql = substr($sql,0,$add_pos).
					" INNER JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
		  			ON (c.categories_id = cd.categories_id
		  			AND cd.language_id=".$_SESSION['languages_id']."
		  			AND cd.categories_description LIKE '%-".SITE_NAME."-%') ".
					substr($sql,$add_pos);
			}
		}
		if($fix==1) {
			if(preg_match("/^select p2c.categories_id from ".TABLE_PRODUCTS." p, ".TABLE_PRODUCTS_TO_CATEGORIES." p2c ".
                   "where p.products_id = '[0-9]+' and p.products_status = '1' ".
                   "and p.products_id = p2c.products_id limit 1$/",$sql)) {
				$sql = str_replace(TABLE_PRODUCTS_TO_CATEGORIES." p2c ",TABLE_PRODUCTS_TO_CATEGORIES." p2c
					INNER JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
					ON (p2c.categories_id=cd.categories_id
					AND cd.language_id=".$_SESSION['languages_id']."
					AND cd.categories_description LIKE '%-".SITE_NAME."-%')
					INNER JOIN ".TABLE_CATEGORIES." as c ON (cd.categories_id=c.categories_id AND c.categories_status=1)",$sql);
            } else {
				$add_pos = $str_pos_products + strlen(TABLE_PRODUCTS . ' p');
				$str_pos_coma = strpos($sql_lower,',',$add_pos);
				if($str_pos_coma!==false) {
					$add_pos = $str_pos_coma;
				} 
				if(($str_pos_where!==false)&&(($str_pos_coma===false)||($str_pos_where<$str_pos_coma))) {
					$add_pos = $str_pos_where;
				}
				$sql = substr($sql,0,$add_pos).
						" INNER JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
						ON (cd.language_id=".$_SESSION['languages_id']."
			  			AND cd.categories_description LIKE '%-".SITE_NAME."-%')						
						RIGHT JOIN ".TABLE_PRODUCTS_TO_CATEGORIES." p2c
			  			ON (p2c.categories_id = cd.categories_id
						AND p.products_id = p2c.products_id) ".
						substr($sql,$add_pos);
             }

God bless you all,
Iasmin from AmazingDiscoveries.org

17 Jul 2008, 7:44 PM
#490
hipctech avatar

hipctech

Totally Zenned

Join Date:
Oct 2004
Location:
Surrey, BC, Canada
Posts:
1,466
Plugin Contributions:
1

Re: MultiSite Module Support Thread

Hello again,
I actually found a problem with the last query in the PHP quoted above. It comes when there is an already set p2c category. Here is the changed code:

				$sql = substr($sql,0,$add_pos).
						" INNER JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
						ON (cd.language_id=".$_SESSION['languages_id']."
			  			AND cd.categories_description LIKE '%-".SITE_NAME."-%')						
						RIGHT JOIN ".TABLE_PRODUCTS_TO_CATEGORIES." prod2cat
			  			ON (prod2cat.categories_id = cd.categories_id
						AND p.products_id = prod2cat.products_id) ".
						substr($sql,$add_pos);

I hope this helps. God bless you,
Iasmin for Amazing Discoveries

18 Jul 2008, 6:41 PM
#491
hipctech avatar

hipctech

Totally Zenned

Join Date:
Oct 2004
Location:
Surrey, BC, Canada
Posts:
1,466
Plugin Contributions:
1

Re: MultiSite Module Support Thread

Hello there,
I would advise that no one take the changes that I posted in consideration yet. There are still some problems with them. There are quite a few queries that return double products because it takes them from the products_to_categories db table as well. It is quite frustrating but I'm trusting in Him who is all wise to guide me and show me how to fix this.
If anyone has some tips or wants to join me in debugging this, you're most than welcome.

God bless you,
Iasmin

18 Jul 2008, 8:37 PM
#492
hipctech avatar

hipctech

Totally Zenned

Join Date:
Oct 2004
Location:
Surrey, BC, Canada
Posts:
1,466
Plugin Contributions:
1

Re: MultiSite Module Support Thread

HiPCTech:

There are quite a few queries that return double products because it takes them from the products_to_categories db table as well.

The query returns double products when it finds more then 1 of the same product_id in the products_to_categories db table. I'll have to leave this until Sunday but I'd greatly appreciate any help. I know that God will help us solve this.

God bless you all and thank you.
Iasmin

21 Jul 2008, 3:13 PM
#493
makenoiz avatar

makenoiz

Zen Follower

Join Date:
Mar 2006
Posts:
284
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Anyone running an upsell or cross sell mod with multisite?

Thanks

22 stores and counting! Ive been zenned.

21 Jul 2008, 10:48 PM
#494
hipctech avatar

hipctech

Totally Zenned

Join Date:
Oct 2004
Location:
Surrey, BC, Canada
Posts:
1,466
Plugin Contributions:
1

Re: MultiSite Module Support Thread

HiPCTech:

The query returns double products when it finds more then 1 of the same product_id in the products_to_categories db table. I'll have to leave this until Sunday but I'd greatly appreciate any help. I know that God will help us solve this.

Hello everyone!
I've been working on this and the good Lord has guided me to the solution. I've tested it on a few pages and it works but it might still need some testing.
Here is the code that replaced lines 90-95.

/* Change added by Iasmin Balaj on July 21, 2008. [email protected] */
				if($str_pos_p2c===false && $str_pos_desc===false)
				{
					$sql = substr($sql,0,$add_pos).
							" INNER JOIN (".TABLE_CATEGORIES_DESCRIPTION." cd, ".TABLE_PRODUCTS_TO_CATEGORIES." p2c)
				  			ON (p2c.categories_id = cd.categories_id
							AND p.products_id = p2c.products_id
				  			AND cd.language_id=".$_SESSION['languages_id']."
				  			AND cd.categories_description LIKE '%-".SITE_NAME."-%') ".
							substr($sql,$add_pos);
					
				}
				// put the new query in the WHERE statement. Find the categories description for this site, match it to p2c and then to the p_id.
				elseif($str_pos_p2c!==false && $str_pos_desc!==false) {
					$str_pos_where = strpos($sql,'where') + 5;
					$sql = substr($sql,0,$str_pos_where).
							" \n(cd.language_id=".$_SESSION['languages_id']."
				  			AND cd.categories_description LIKE '%-".SITE_NAME."-%'
				  			AND p2c.categories_id = cd.categories_id
							AND p.products_id = p2c.products_id)\n ".
							substr($sql,$str_pos_where);
				}
				// put the new query in the WHERE statement IF p2c is declared but CAT_DESC is not.
				elseif($str_pos_p2c!==false) {
					$str_pos_where = strpos($sql,'where');
					$sql = substr($sql,0,$str_pos_where).
							', '.TABLE_CATEGORIES_DESCRIPTION.' cd '.
							substr($sql,$str_pos_where);
					$str_pos_where = strpos($sql,'where') + 5;
					$sql = substr($sql,0,$str_pos_where).
							' (p2c.categories_id = cd.categories_id AND p.products_id = p2c.products_id AND cd.language_id=1 AND cd.categories_description LIKE \'%'.SITE_NAME.'%\') AND '.
							substr($sql,$str_pos_where);
				} 
				// 
				else {
					$sql = substr($sql,0,$add_pos).
							" INNER JOIN ".TABLE_CATEGORIES_DESCRIPTION." cd
				  			ON (p.master_categories_id = cd.categories_id
				  			AND cd.language_id=".$_SESSION['languages_id']."
				  			AND cd.categories_description LIKE '%-".SITE_NAME."-%') ".
							substr($sql,$add_pos);
					$str_pos_where = strpos($sql,'where') + 5;
					$sql = substr($sql,0,$str_pos_where).
							" \n(p.products_id = p2c.products_id
                                AND p.master_categories_id = p2c.categories_id)\n ".
							substr($sql,$str_pos_where);
				}

I hope that this helps and please let me know if there are any errors.
God bless you,
Iasmin

29 Jul 2008, 12:27 PM
#495
pae2008 avatar

pae2008

New Zenner

Join Date:
Jul 2008
Posts:
28
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Hi there, I'm having a problem with installing this mod to a site. The problem appears in includes/modules/sideboxes/featured.php. According to the instructions, I am supposed to find Line 25 and replace this:
```php
$random_featured_product = zen_random_select($random_featured_products_query);

with this:

   ```php
 $random_featured_product = zen_random_select(cat_filter($random_featured_products_query));

However, this is how my file looks for lines 27-29:

    // randomly select ONE featured product from the list retrieved:
    //$random_featured_product = zen_random_select($random_featured_products_query);
    $random_featured_product = $db->ExecuteRandomMulti($random_featured_products_query, MAX_RANDOM_SELECT_FEATURED_PRODUCTS);

As you can see, the line I am supposed to edit is commented out. I do not believe I have installed any mods that would have edited this file but I do need assistance in what I should do next. Got any ideas? I am using Zen Cart 1.3.8a.

Thanks,
PAE2008

29 Jul 2008, 12:46 PM
#496
pae2008 avatar

pae2008

New Zenner

Join Date:
Jul 2008
Posts:
28
Plugin Contributions:
0

Re: MultiSite Module Support Thread

It appear to also happen at includes/modules/sideboxes/specials.php

Line 34:
    $random_specials_sidebox_product = zen_random_select($random_specials_sidebox_product_query);
Replace by:
    $random_specials_sidebox_product = zen_random_select(cat_filter($random_specials_sidebox_product_query));

And this is what I have:

//    $random_specials_sidebox_product = zen_random_select($random_specials_sidebox_product_query);
    $random_specials_sidebox_product = $db->ExecuteRandomMulti($random_specials_sidebox_product_query, MAX_RANDOM_SELECT_SPECIALS);

I'm beginning to think that there has been some changes in the Zen Cart code that have not been changed here yet... I would really like to use this mod so any suggestions would be helpful.

29 Jul 2008, 12:57 PM
#497
pae2008 avatar

pae2008

New Zenner

Join Date:
Jul 2008
Posts:
28
Plugin Contributions:
0

Re: MultiSite Module Support Thread

PAE2008:

It appear to also happen at includes/modules/sideboxes/specials.php

Line 34:
$random_specials_sidebox_product = zen_random_select($random_specials_sidebox_product_query);
Replace by:
$random_specials_sidebox_product = zen_random_select(cat_filter($random_specials_sidebox_product_query));

> And this is what I have:
> 
> ```php
//    $random_specials_sidebox_product = zen_random_select($random_specials_sidebox_product_query);
    $random_specials_sidebox_product = $db->ExecuteRandomMulti($random_specials_sidebox_product_query, MAX_RANDOM_SELECT_SPECIALS);

I'm beginning to think that there has been some changes in the Zen Cart code that have not been changed here yet... I would really like to use this mod so any suggestions would be helpful.
Ha! I might be on to something... To properly update these files, would I just add cat_filter after ExecuteRandomMulti(?

For example (includes/modules/sideboxes/specials.php):

$random_specials_sidebox_product = $db->ExecuteRandomMulti(cat_filter($random_specials_sidebox_product_query), MAX_RANDOM_SELECT_SPECIALS);

If someone could confirm this, it would be very helpful. Sorry for all of the messages... I did not mean to spam the thread if I did so. I could not find any reference anywhere else in here and my edit time kept expiring as I continued to edit files.

PAE2008

29 Jul 2008, 1:05 PM
#498
jvoce avatar

jvoce

New Zenner

Join Date:
Jul 2006
Location:
Toronto, ON
Posts:
87
Plugin Contributions:
0

Re: MultiSite Module Support Thread

PAE2008:

Ha! I might be on to something... To properly update these files, would I just add cat_filter after ExecuteRandomMulti(?

For example (includes/modules/sideboxes/specials.php):

$random_specials_sidebox_product = $db->ExecuteRandomMulti(cat_filter($random_specials_sidebox_product_query), MAX_RANDOM_SELECT_SPECIALS);

> 
> If someone could confirm this, it would be very helpful. Sorry for all of the messages... I did not mean to spam the thread if I did so. I could not find any reference anywhere else in here and my edit time kept expiring as I continued to edit files.
> 
> PAE2008

I haven't looked into these specific files since you've posted, but I've found the adding the (cat_filter......) has worked great for additional features that weren't included in the original mod. It definately doesn't hurt to try. It probably will work. Just remember what files you changed though, just in case it doesn't work.

Blessings,

Jaret
29 Jul 2008, 1:08 PM
#499
jvoce avatar

jvoce

New Zenner

Join Date:
Jul 2006
Location:
Toronto, ON
Posts:
87
Plugin Contributions:
0

Re: MultiSite Module Support Thread

PAE2008:

Ha! I might be on to something... To properly update these files, would I just add cat_filter after ExecuteRandomMulti(?

For example (includes/modules/sideboxes/specials.php):

$random_specials_sidebox_product = $db->ExecuteRandomMulti(cat_filter($random_specials_sidebox_product_query), MAX_RANDOM_SELECT_SPECIALS);

> 
> PAE2008

I didn't notice this at first, but I wouldn't close the bracket after $random_specials_sidebox_product_query, but rather following MAX_RANDOM_SELECT_SPECIALS)

```php
$random_specials_sidebox_product = $db->ExecuteRandomMulti(cat_filter($random_specials_sidebox_product_query, MAX_RANDOM_SELECT_SPECIALS));
1 Aug 2008, 9:03 AM
#500
makenoiz avatar

makenoiz

Zen Follower

Join Date:
Mar 2006
Posts:
284
Plugin Contributions:
0

Re: MultiSite Module Support Thread

Just want to thank those who helped me in this thread. I now have 12 stores running on one DB. All different domains, IPs. Its great. Thanks again..

22 stores and counting! Ive been zenned.