Merchant Affiliate Program

Support Forum
It is currently Tue Mar 28, 2017 9:44 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: VirtueMart Integration
PostPosted: Wed Dec 23, 2009 3:57 pm 
Offline
Site Admin

Joined: Mon Mar 29, 2004 3:56 pm
Posts: 114
To integrate MyGiftList with a site that uses VirtueMart.net for e-commerce, cut and paste the "Add to MyGiftList" HTML code below into the /components/com_virtuemart/themes/your theme name/templates/product_details/flypage.tpl.php file of your cart. There are several flypage files in this folder. You should add it to the ones that you use or all of them. This code was tested with VirtueMart 1.1.4 stable.

The code should go immediately after the Add to Cart button code. The Add to Cart button is this code snippet:
Code:
<?php echo $addtocart ?>


Remember to change "Your Affiliate ID" below to your MyGiftList Affiliate ID and "Your Store Name" below to the name of your store.


Code:
<!-- BEGIN MyGiftList Code -->
<!--  Add this code before the </form> end tag for the Add to Cart button -->
<!--  change "Your Affiliate ID" below to your MyGiftList Affiliate ID -->
<!--  change "Your Store Name" below to the name of your store -->

&nbsp;&nbsp;<input type="image" onclick='javascript:virtuemartMGLpopup("Your Affiliate ID","Your Store Name","virtuemart");return false;' src="http://images.mygiftlist.com/gif/AddtoMyGiftList7e.gif" width=68 height=26 border=0 alt="Click to Add to MyGiftList!" align=right vspace=5>

<textarea rows=1 cols=10 name=giftName id=giftName style="display:none"><?php echo strip_tags($product_name); ?></textarea>
<textarea rows=1 cols=10 name=giftDescription id=giftDescription style="display:none"><?php echo strip_tags($product_description); ?></textarea>

<script language=javascript>
function virtuemartMGLpopup(refsource, storename, cartname) {
   var giftPrice = "";
   var giftName = "";
   var giftDescription = "";
   var m;
   var u = "";
   var n;
   var f;
   
   f = document.forms["addtocart"];
    //alert(f);
   if (f) {
       giftPrice = document.getElementsByClassName("productPrice")[0].innerHTML;
      //alert(giftPrice[0].innerHTML);
      giftName = document.getElementById("giftName").innerHTML;
      //alert(document.getElementById("giftName"));
      //alert(giftName);
      giftDescription = document.getElementById("giftDescription").innerHTML;
      //alert(giftDescription);
    
      for (var i = 0; i < f.elements.length; i++) {
         m = f.elements[i].selectedIndex;
         n = f.elements[i].name
         

         if (m > -1) {
            u = u + f.elements[i].options[m].text + ", ";
           }
         if (f.elements[i].name == "quantity[]" ) {
               u = u + "Quantity=" + f.elements[i].value + ", ";
         }
       }
   }
   if ( u != "" ) {
      u = u.substr(0, u.length-2);
      u = "I would like these options: " + u;
      giftDescription = u + ".  " + giftDescription;
   }

   u = "http://www.mygiftlist.com/register_gift.asp?refSource=" + escape(refsource) + "&giftURL=" + escape(document.URL) + "&giftName=" + escape(giftName) + "&giftRetailer=" + escape(storename) + "&giftCart=" + escape(cartname) + "&giftPrice=" + escape(giftPrice) + "&giftDescription=" + escape(giftDescription);
   var mgl = window.open(u,"MGL","width=720,height=500,top=60,left=100,resizable,scrollbars");
}

document.getElementsByClassName = function(cl) {
   var retnode = [];
   var myclass = new RegExp('\\b'+cl+'\\b');
   var   elem = this.getElementsByTagName('*');
   for (var i = 0; i < elem.length; i++) {
      var classes = elem[i].className;
      if (myclass.test(classes)) retnode.push(elem[i]);
   }
   return retnode;
}
</script>

<!-- End MyGiftList Code -->



For example, here is the Add to MyGiftList button code added to a sample flypage.tpl.php file:


Code:
<?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
mm_showMyFileName(__FILE__);
 ?>

<?php echo $buttons_header // The PDF, Email and Print buttons ?>

<?php
if( $this->get_cfg( 'showPathway' )) {
   echo "<div class=\"pathway\">$navigation_pathway</div>";
}
if( $this->get_cfg( 'product_navigation', 1 )) {
   if( !empty( $previous_product )) {
      echo '<a class="previous_page" href="'.$previous_product_url.'">'.shopMakeHtmlSafe($previous_product['product_name']).'</a>';
   }
   if( !empty( $next_product )) {      
      echo '<a class="next_page" href="'.$next_product_url.'">'.shopMakeHtmlSafe($next_product['product_name']).'</a>';
   }
}
?>
<br style="clear:both;" />
<table border="0" style="width: 100%;">
  <tbody>
   <tr>
<?php  if( $this->get_cfg('showManufacturerLink') ) { $rowspan = 5; } else { $rowspan = 4; } ?>
     <td width="33%" rowspan="<?php echo $rowspan; ?>" valign="top"><br/>
        <?php echo $product_image ?><br/><br/><?php echo $this->vmlistAdditionalImages( $product_id, $images ) ?></td>
     <td rowspan="1" colspan="2">
     <h1><?php echo $product_name ?> <?php echo $edit_link ?></h1>
     </td>
   </tr>
   <?php if( $this->get_cfg('showManufacturerLink')) { ?>
      <tr>
        <td rowspan="1" colspan="2"><?php echo $manufacturer_link ?><br /></td>
      </tr>
   <?php } ?>
   <tr>
      <td width="33%" valign="top" align="left">
         <?php echo $product_price_lbl ?>
         <?php echo $product_price ?><br /></td>
      <td valign="top"><?php echo $product_packaging ?><br /></td>
   </tr>
   <tr>
     <td colspan="2"><?php echo $ask_seller ?></td>
   </tr>
   <tr>
     <td rowspan="1" colspan="2"><hr />
        <?php echo $product_description ?><br/>
        <span style="font-style: italic;"><?php echo $file_list ?></span>
     </td>
   </tr>
   <tr>
     <td><?php
           if( $this->get_cfg( 'showAvailability' )) {
              echo $product_availability;
           }
           ?><br />
     </td>
     <td colspan="2"><br /><?php echo $addtocart ?><!-- BEGIN MyGiftList Code -->
<!--  Add this code before the </form> end tag for the Add to Cart button -->
<!--  change "Your Affiliate ID" below to your MyGiftList Affiliate ID -->
<!--  change "Your Store Name" below to the name of your store -->

&nbsp;&nbsp;<input type="image" onclick='javascript:virtuemartMGLpopup("Your Affiliate ID","Your Store Name","virtuemart");return false;' src="http://images.mygiftlist.com/gif/AddtoMyGiftList7e.gif" width=68 height=26 border=0 alt="Click to Add to MyGiftList!" align=right vspace=5>

<textarea rows=1 cols=10 name=giftName id=giftName style="display:none"><?php echo strip_tags($product_name); ?></textarea>
<textarea rows=1 cols=10 name=giftDescription id=giftDescription style="display:none"><?php echo strip_tags($product_description); ?></textarea>

<script language=javascript>
function virtuemartMGLpopup(refsource, storename, cartname) {
   var giftPrice = "";
   var giftName = "";
   var giftDescription = "";
   var m;
   var u = "";
   var n;
   var f;
   
   f = document.forms["addtocart"];
    //alert(f);
   if (f) {
       giftPrice = document.getElementsByClassName("productPrice")[0].innerHTML;
      //alert(giftPrice[0].innerHTML);
      giftName = document.getElementById("giftName").innerHTML;
      //alert(document.getElementById("giftName"));
      //alert(giftName);
      giftDescription = document.getElementById("giftDescription").innerHTML;
      //alert(giftDescription);
    
      for (var i = 0; i < f.elements.length; i++) {
         m = f.elements[i].selectedIndex;
         n = f.elements[i].name
         

         if (m > -1) {
            u = u + f.elements[i].options[m].text + ", ";
           }
         if (f.elements[i].name == "quantity[]" ) {
               u = u + "Quantity=" + f.elements[i].value + ", ";
         }
       }
   }
   if ( u != "" ) {
      u = u.substr(0, u.length-2);
      u = "I would like these options: " + u;
      giftDescription = u + ".  " + giftDescription;
   }

   u = "http://www.mygiftlist.com/register_gift.asp?refSource=" + escape(refsource) + "&giftURL=" + escape(document.URL) + "&giftName=" + escape(giftName) + "&giftRetailer=" + escape(storename) + "&giftCart=" + escape(cartname) + "&giftPrice=" + escape(giftPrice) + "&giftDescription=" + escape(giftDescription);
   var mgl = window.open(u,"MGL","width=720,height=500,top=60,left=100,resizable,scrollbars");
}

document.getElementsByClassName = function(cl) {
   var retnode = [];
   var myclass = new RegExp('\\b'+cl+'\\b');
   var   elem = this.getElementsByTagName('*');
   for (var i = 0; i < elem.length; i++) {
      var classes = elem[i].className;
      if (myclass.test(classes)) retnode.push(elem[i]);
   }
   return retnode;
}
</script>

<!-- End MyGiftList Code -->    
     </td>
   </tr>
   <tr>
     <td colspan="3"><?php echo $product_type ?></td>
   </tr>
   <tr>
     <td colspan="3"><hr /><?php echo $product_reviews ?></td>
   </tr>
   <tr>
     <td colspan="3"><?php echo $product_reviewform ?><br /></td>
   </tr>
   <tr>
     <td colspan="3"><?php echo $related_products ?><br />
      </td>
   </tr>
   <?php if( $this->get_cfg('showVendorLink')) { ?>
      <tr>
        <td colspan="3"><div style="text-align: center;"><?php echo $vendor_link ?><br /></div><br /></td>
      </tr>
   <?php  } ?>
  </tbody>
</table>
<?php
if( !empty( $recent_products )) { ?>
   <div class="vmRecent">
   <?php echo $recent_products; ?>
   </div>
<?php
}
if( !empty( $navigation_childlist )) { ?>
   <?php echo $VM_LANG->_('PHPSHOP_MORE_CATEGORIES') ?><br />
   <?php echo $navigation_childlist ?><br style="clear:both"/>
<?php
} ?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group