Zen Cart Logo
Forums / All Other Contributions/Addons / Better Together mod

Better Together mod

Locked

Views: 1,648

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
16 Aug 2008, 11:31 AM
#1
coolman avatar

coolman

New Zenner

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

Better Together mod

When using the "Better Together" mod it only shows the discount linking as text, is there a way to add a thumbnail?

example:

Buy this item and get "some product " <thumbnail pic here> for 50% off.

16 Aug 2008, 12:09 PM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,694
Plugin Contributions:
56

Re: Better Together mod

I am planning on adding capabilities like this in a future release.

17 Aug 2008, 6:08 AM
#3
coolman avatar

coolman

New Zenner

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

Re: Better Together mod

// call this in product info page
    function get_discount_info($id, $cat) { 
       global $order, $currencies;
       $response_arr = array(); 

       for ($dis=0, $n=count($this->twoferlist); $dis<$n; $dis++) {
           $li = $this->twoferlist[$dis]; 
           $match = 0;
           if ( ($li->flavor == TWOFER_PROD) && 
                ($li->ident1 == $id)  ) {
              $match = 1; 
              if ($this->nocontext == 0) {
                 $disc_string = TWOFER_PROMO_STRING; 
              } else {
                 $disc_link = '<a href="'.zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $li->ident1).'">'. zen_get_products_name($li->ident1, $_SESSION['languages_id']).'</a>';
                 $disc_string = QUALIFY; 
                 $disc_string .= GET_THIS; 
                 $disc_string .= SECOND; 
                 $disc_string .= $disc_link;
                 $disc_string .= FREE;
              }
           } else if ( ($li->flavor == TWOFER_CAT) && 
                       ($li->ident1 == $cat) ) {
              $match = 1; 
              if ($this->nocontext == 0) {
                 $disc_string = TWOFER_CAT_PROMO_STRING; 
              } else {
                 $disc_link = '<a href="'.zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $id).'">'. zen_get_products_name($id, $_SESSION['languages_id']).'</a>';
                 $disc_string = QUALIFY; 
                 $disc_string .= GET_THIS; 
                 $disc_string .= SECOND; 
                 $disc_string .= $disc_link;
                 $disc_string .= FREE;
              }
           }
           if ($match == 1) {
              $response_arr[] = $disc_string;
              continue;
           }
       }

       for ($dis=0, $n=count($this->discountlist); $dis<$n; $dis++) {
           $li = $this->discountlist[$dis]; 
           $match = 0; 
           if ( ($li->flavor == PROD_TO_PROD) &&
                ($li->ident1 == $id) ) {
              $match = 1; 
              $disc_link = '<a href="'.zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $li->ident2).'">'. zen_get_products_name($li->ident2, $_SESSION['languages_id']).'</a>';
//////////////////////////////////////////////////////////////////////Added by Me///////////////////////////////////////////////////////////////////////////////			  		  
			    $disc_prod_image_id = $li->ident2;
			  	$result = mysql_query("SELECT * FROM products WHERE products_id='$disc_prod_image_id'");
			  	while($row = mysql_fetch_array($result))
			  	{
  					$show_image = $row['products_image'];
  					echo "<br />";
					echo zen_image(DIR_WS_IMAGES . $show_image, $category_icon_display_name, CATEGORY_ICON_IMAGE_WIDTH, CATEGORY_ICON_IMAGE_HEIGHT);
 			    }
/////////////////////////////////////////////////////////////////// End Added by Me//////////////////////////////////////////////////////////////////////////				
           } else if ( ($li->flavor == PROD_TO_CAT) &&
                ($li->ident1 == $id) ) {
              $match = 1; 
              $disc_link = '<a href="'.zen_href_link(FILENAME_DEFAULT, 'cPath=' . $li->ident2).'">'. zen_get_category_name($li->ident2, $_SESSION['languages_id']).'</a>';
           } else if ( ($li->flavor == CAT_TO_CAT) &&
                ($li->ident1 == $cat) ) {
              $match = 1; 
              $disc_link = '<a href="'.zen_href_link(FILENAME_DEFAULT, 'cPath=' . $li->ident2).'">'. zen_get_category_name($li->ident2, $_SESSION['languages_id']).'</a>';
           }
           if ($match == 1) {
              if ($this->nocontext == 0)  
                 $disc_string = BUY_THIS_ITEM; 
              else 
                 $disc_string = QUALIFY; 
              if ($li->flavor == PROD_TO_PROD) {
                  $disc_string .= GET_THIS; 
              } else {
                  $disc_string .= GET_ANY; 
              } 
              if ( ($li->flavor == PROD_TO_PROD)  &&
                   ($li->ident1 == $li->ident2) && 
                   ($this->nocontext == 0) ) {
                     $disc_string .= SECOND_ONE;
              } else { 
                  $disc_string .= $disc_link; 
              }
              $disc_string .= " "; 
              if ($li->type == "%") {
                 if ($li->amt != 100) {
                    $str_amt = $li->amt . "%"; 
                    $off_string = sprintf(OFF_STRING_PCT, $str_amt);
                 } else {
                    $off_string = FREE_STRING;
                 }
                 $disc_string .= $off_string;
              } else {
                 $curr_string = $currencies->format($li->amt, true, $order->info['currency'], $order->info['currency_value']);
                 $off_string = sprintf(OFF_STRING_CURR, $curr_string); 
                 $disc_string .= $off_string;
              }
              $response_arr[] = $disc_string;
           }
       }
       return $response_arr;
    }

    // call this in product info page to show what to do to get a 
    // discount (the opposite way.)
    function get_reverse_discount_info($id, $cat) { 
       global $order, $currencies;
       $response_arr = array(); 

       for ($dis=0, $n=count($this->discountlist); $dis<$n; $dis++) {
           $li = $this->discountlist[$dis]; 
           $match = 0; 
           if ($li->ident2 == $li->ident1) {
               continue;
           }
           $this_string = REV_GET_DISC; 
           if ( ($li->flavor == PROD_TO_PROD) &&
                ($li->ident2 == $id) ) {
              $match = 1; 
              $disc_link = '<a href="'.zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $li->ident1).'">'. zen_get_products_name($li->ident1, $_SESSION['languages_id']).'</a>';
//////////////////////////////////////////////////Added by Me//////////////////////////////////////////////////////////			  
			  $disc_prod_image_id = $li->ident1;
			  $result = mysql_query("SELECT * FROM products WHERE products_id='$disc_prod_image_id'");
			  while($row = mysql_fetch_array($result))
			  	{
  					$show_image = $row['products_image'];
  					echo "<br />";
					echo zen_image(DIR_WS_IMAGES . $show_image, $category_icon_display_name, CATEGORY_ICON_IMAGE_WIDTH, CATEGORY_ICON_IMAGE_HEIGHT);
 			    }
//////////////////////////////////////////////////////End Added by Me/////////////////////////////////////////////////////////				
              if ($this->nocontext == 1) { 
                   $this_string = GET_YOUR_PROD . zen_get_products_name($li->ident2, $_SESSION['languages_id']); 
              }
           } else if ( ($li->flavor == PROD_TO_CAT) &&
                ($li->ident2 == $cat) ) {
              $match = 1; 
              $disc_link = '<a href="'.zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $li->ident1).'">'. zen_get_products_name($li->ident1, $_SESSION['languages_id']).'</a>';
              if ($this->nocontext == 1) { 
                   $this_string = GET_YOUR_CAT . zen_get_category_name($li->ident2, $_SESSION['languages_id']); 
              }
           } else if ( ($li->flavor == CAT_TO_CAT) &&
                ($li->ident2 == $cat) ) {
              $match = 1; 
              $disc_link = '<a href="'.zen_href_link(FILENAME_DEFAULT, 'cPath=' . $li->ident1).'">'. zen_get_category_name($li->ident1, $_SESSION['languages_id']).'</a>';
              if ($this->nocontext == 1) { 
                   $this_string = GET_YOUR_CAT . zen_get_category_name($li->ident2, $_SESSION['languages_id']); 
              }
           }
           if ($match == 1) {
              if ( ($li->flavor == PROD_TO_PROD) || 
                   ($li->flavor == PROD_TO_CAT) )  {
                  $disc_string = REV_GET_THIS; 
              } else {
                  $disc_string = REV_GET_ANY; 
              } 
              $disc_string .= $disc_link; 
              $disc_string .= $this_string; 
              if ($li->type == "%") {
                 if ($li->amt != 100) {
                    $str_amt = $li->amt . "%"; 
                    $off_string = sprintf(OFF_STRING_PCT, $str_amt);
                 } else {
                    $off_string = FREE_STRING;
                 }
                 $disc_string .= $off_string;
              } else {
                 $curr_string = $currencies->format($li->amt, true, $order->info['currency'], $order->info['currency_value']);
                 $off_string = sprintf(OFF_STRING_CURR, $curr_string); 
                 $disc_string .= $off_string;
              }
              $response_arr[] = $disc_string;
           }
       }
       return $response_arr;
    }
17 Aug 2008, 6:12 AM
#4
coolman avatar

coolman

New Zenner

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

Re: Better Together mod

The code will use the same image used for the product listing thubnail.

17 Aug 2008, 10:07 PM
#5
coolman avatar

coolman

New Zenner

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

Re: Better Together mod

sorry, in the line.
echo zen_image(DIR_WS_IMAGES . $show_image, $category_icon_display_name, CATEGORY_ICON_IMAGE_WIDTH, CATEGORY_ICON_IMAGE_HEIGHT)

This can be removed it does not do anything. Do be sure to keep the ) at the end.
, CATEGORY_ICON_IMAGE_WIDTH, CATEGORY_ICON_IMAGE_HEIGHT

18 Aug 2008, 8:09 PM
#6
heathenmagic avatar

heathenmagic

Totally Zenned

Join Date:
May 2005
Location:
England
Posts:
730
Plugin Contributions:
0

Re: Better Together mod

Hello Coolman,

This is a great idea. I got an error when I tried it, but I think it might be because I am on php 5.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/thegemtr/public_html/includes/modules/order_total/ot_better_together.php on line 474

Heathenmagic