Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Simple way to show buy together tab on all products from combination Rate Topic   - - - - -

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1247 posts

Posted 01 April 2013 - 08:38 PM #1

Hi there fellow members,

ex: prod 1 have combination: prod 1 + prod 2 + prod 3 = X price
Buy Together tab will appear only on prod 1 and with the trick bellow will appear also on prod 2 and prod 3

for this you need to add in file addons/buy_together/func.php

after:
$chains = db_get_array("SELECT $fields FROM ?:buy_together AS items LEFT JOIN ?:products AS p ON p.product_id = items.product_id LEFT JOIN ?:buy_together_descriptions AS descr ON items.chain_id = descr.chain_id AND descr.lang_code = ?s $condition", $lang_code);

add:
//add by hungryweb.net ****************************************************************
if (empty($chains) && AREA == 'C') {
  if (!empty($params['product_id'])){
   $conditions[0] = 'products LIKE \'%product_id";s:'.strlen($params['product_id']).':"'.$params['product_id'].'"%\'';
  }
  $condition = 'WHERE ' . implode(' AND ', $conditions);
  $chains = db_get_array("SELECT $fields FROM ?:buy_together AS items LEFT JOIN ?:products AS p ON p.product_id = items.product_id LEFT JOIN ?:buy_together_descriptions AS descr ON items.chain_id = descr.chain_id AND descr.lang_code = ?s $condition", $lang_code);
}
//end *****************************************************************************************

Tested on v3.0.6

I hope that helps,

---
Valentin

 
  • Magpie Don
  • Senior Member
  • Members
  • Join Date: 01-Apr 09
  • 813 posts

Posted 02 April 2013 - 05:10 AM #2

This has been an annoyance in the Buy Together addon from the beginning. Thanks for the fix.

CS-Cart Ultimate ver 4.3.5


 
  • tom437
  • Senior Member
  • Members
  • Join Date: 10-Jul 10
  • 635 posts

Posted 11 April 2013 - 02:27 AM #3

Hi there fellow members,

ex: prod 1 have combination: prod 1 + prod 2 + prod 3 = X price
Buy Together tab will appear only on prod 1 and with the trick bellow will appear also on prod 2 and prod 3

for this you need to add in file addons/buy_together/func.php

after:

$chains = db_get_array("SELECT $fields FROM ?:buy_together AS items LEFT JOIN ?:products AS p ON p.product_id = items.product_id LEFT JOIN ?:buy_together_descriptions AS descr ON items.chain_id = descr.chain_id AND descr.lang_code = ?s $condition", $lang_code);

add:
//add by hungryweb.net ****************************************************************
if (empty($chains) && AREA == 'C') {
  if (!empty($params['product_id'])){
   $conditions[0] = 'products LIKE \'%product_id";s:'.strlen($params['product_id']).':"'.$params['product_id'].'"%\'';
  }
  $condition = 'WHERE ' . implode(' AND ', $conditions);
  $chains = db_get_array("SELECT $fields FROM ?:buy_together AS items LEFT JOIN ?:products AS p ON p.product_id = items.product_id LEFT JOIN ?:buy_together_descriptions AS descr ON items.chain_id = descr.chain_id AND descr.lang_code = ?s $condition", $lang_code);
}
//end *****************************************************************************************

Tested on v3.0.6

I hope that helps,

---
Valentin

Thanks
3.0.4
Hosting for less.
www.step2stephosting.com

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1247 posts

Posted 20 April 2013 - 05:45 PM #4

You're welcome

 
  • Angeltown
  • Advanced Member
  • Members
  • Join Date: 05-Feb 15
  • 136 posts

Posted 19 March 2015 - 09:52 AM #5

Hi there fellow members,

ex: prod 1 have combination: prod 1 + prod 2 + prod 3 = X price
Buy Together tab will appear only on prod 1 and with the trick bellow will appear also on prod 2 and prod 3

for this you need to add in file addons/buy_together/func.php

after:

$chains = db_get_array("SELECT $fields FROM ?:buy_together AS items LEFT JOIN ?:products AS p ON p.product_id = items.product_id LEFT JOIN ?:buy_together_descriptions AS descr ON items.chain_id = descr.chain_id AND descr.lang_code = ?s $condition", $lang_code);

add:
//add by hungryweb.net ****************************************************************
if (empty($chains) && AREA == 'C') {
  if (!empty($params['product_id'])){
   $conditions[0] = 'products LIKE \'%product_id";s:'.strlen($params['product_id']).':"'.$params['product_id'].'"%\'';
  }
  $condition = 'WHERE ' . implode(' AND ', $conditions);
  $chains = db_get_array("SELECT $fields FROM ?:buy_together AS items LEFT JOIN ?:products AS p ON p.product_id = items.product_id LEFT JOIN ?:buy_together_descriptions AS descr ON items.chain_id = descr.chain_id AND descr.lang_code = ?s $condition", $lang_code);
}
//end *****************************************************************************************

Tested on v3.0.6

I hope that helps,

---
Valentin


Added & working on MV v.4.2.4. Thank you so much!

CS-Cart 4.7.4 & CS-Cart Multi-Vendor 4.9.1


 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1247 posts

Posted 13 April 2016 - 05:58 AM #6

Update for CS-Cart 4.3.6

#file
addons/buy_together/func.php
#after:
$chains = db_get_array("SELECT {$fields} FROM ?:buy_together AS items {$joins} {$condition}");
#add:
//add by hungryweb.net ****************************************************************
if (empty($chains) && AREA == 'C') {
  if (!empty($params['product_id'])){
   $conditions['product_id'] = 'products LIKE \'%"product_id";s:'.strlen($params['product_id']).':"'.$params['product_id'].'"%\'';
  }
  $condition = 'WHERE ' . implode(' AND ', $conditions);
  $chains = db_get_array("SELECT {$fields} FROM ?:buy_together AS items {$joins} {$condition}");
}
//end *********************************************************************************
Tested on v4.3.6

I hope that helps,

---
Valentin

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11306 posts

Posted 14 April 2016 - 01:41 AM #7

There are also now buy_together_get_chains_pre, buy_together_get_chains_post and buy_together_get_chains hooks for chain manipulation in the buy_together addon.
Using them means you don't end up with a modified distributed file to remember at next upgrade.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1247 posts

Posted 14 April 2016 - 03:17 AM #8

Thank you @tbirnseth for your notice and push :)

 

Please add in :

 

1.

#file

app/addons/my_changes/init.php

#content

<?php

if (!defined('BOOTSTRAP')) { die('Access denied'); }

fn_register_hooks(
    'buy_together_get_chains'
);

2.

#file

app/addons/my_changes/func.php

#content

<?php

if (!defined('BOOTSTRAP')) { die('Access denied'); }

function fn_my_changes_buy_together_get_chains($params, $auth, $lang_code, $fields, &$conditions, $joins){
	if (AREA == 'C' && !empty($conditions['product_id'])) {
		$condition = 'WHERE ' . implode(' AND ', $conditions);
		$fields = implode(', ', $fields);
		$joins = implode(' ', $joins);

		$chains = db_get_array("SELECT {$fields} FROM ?:buy_together AS items {$joins} {$condition}");
		if(empty($chains)){
			$conditions['product_id'] = 'products LIKE \'%"product_id";s:'.strlen($params['product_id']).':"'.$params['product_id'].'"%\'';
		}
	}
}

* My Changes add-on is required to be active for this to work

* If the folder structure is missing you need to create

* This modification will require a extra mysql query but should not affect in any way website speed

 

I hope that helps,

---
Valentin
part of hungryweb.net



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11306 posts

Posted 14 April 2016 - 06:09 PM #9

Thank you @tbirnseth for your notice and push :)

Sometimes a bit more work up front, but huge time (and frustration) savings in the long term (until they change the hook of course!)

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.