Jump to content

Add contact list to viewcart.tpl


bss42

Recommended Posts

Hello,

First sorry for my poor english ( i'm french)

Here is my request :

I wan't to add the contact customer list in my order form ( contact from the customer account ) so that when my customer order a product he had to choose a contact ( from a value list )

how can i retrieve the contact list in the viewcart.tpl ? i try to add a php file with include and assign the variable but this do not work :

 

My php files :

 

<?php

$bdd = new PDO('mysql:host=localhost;dbname=portal', 'xxx', 'xxx');

$query = $bdd->prepare("SELECT * FROM tblcontacts where userid =".(int)$_SESSION['uid']);

$query->execute();

$contacts = array();

$contacts[0]['firstname'] = " Choisissez votre client";

$i = 1;

while($data = $query->fetch()){

$contacts[$i]['id'] = $data['id'];

$contacts[$i]['firstname'] = $data['firstname'];

$contacts[$i]['lastname'] = $data['lastname'];

$contacts[$i]['companyname'] = $data['companyname'];

$contacts[$i]['email'] = $data['email'];

$i++;

}

$smartyvalues["contacts"] = $contacts;

 

?>

 

and in my viewcart.tpl

 

{foreach from=$contacts item=contact}

<option value="{$contact.id}"{if $contact.id eq $contacid} selected="selected"{/if}>{$contact.companyname}-{$contact.firstname} {$contact.lastname}</option>

{/foreach}

 

 

But my list is empty just as the php files is not read, is there a way to pass variables from one template to another ( eg : contacts array from clientareacontacts.tpl to viewcart.tpl )

 

Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated