...

View Full Version : loops help please.



LJackson
09-20-2009, 10:51 PM
Hi all,

ok i have this code

$oClient = ClientFactory::getClient();
$merchantcolumns = array(sStrapline,sDescription,sLogoUrl,sDisplayUrl,sClickThroughUrl,oDiscountCode);
$singlemerchantwithcodes = array('iMerchantId' => array(1599), "sColumnToReturn" => $merchantcolumns);
$oResponse= $oClient->call('getMerchant', $singlemerchantwithcodes);

$iId = $oResponse->oMerchant->iId;
$sName =$oResponse->oMerchant->sName;
$sStrapline = $oResponse->oMerchant->sStrapline;
$sDescription = $oResponse->oMerchant->sDescription;
$sLogoUrl = $oResponse->oMerchant->sLogoUrl;
$sDisplayUrl = $oResponse->oMerchant->sDisplayUrl;
$sClickThroughUrl = $oResponse->oMerchant->sClickThroughUrl;
echo '<a href="'.$sClickThroughUrl.'" title="'.$sName.'">'.$sName.'</a><br/>'.$sStrapline.'<br/><img src="'.$sLogoUrl.'" alt="'.$sName.'" /><br/>'.$sDescription.'';
$arraycheck1 = $oResponse->oMerchant->oDiscountCode;
if(!empty($arraycheck1))
{
echo '<div style="margin: 5px 0; background: #D5D5D5; line-height: 0; height: 1px;"></div>
<h3>Vouchers for '.$sName.'</h3>';
foreach($oResponse->oMerchant->oDiscountCode as $key=>$details2)
{
$sCode = $details2->sCode;
$sDescription = $details2->sDescription;
$sUrl = $details2->sUrl;
$sEndDate = $details2->sEndDate;

if ($sUrl<>'')
{
echo '<div style="margin: 5px 0; background: #D5D5D5; line-height: 0;
height: 1px;"></div><a href="'.$sUrl.'" title="'.$sName.'"><img src="'
.$sLogoUrl.'" alt="'.$sName.'" border="0"/></a><br><b>Voucher Code:
<a href="'.$sUrl.'">'.$sCode.'</a></b><br/> <font color="red">(Expires '
.$sEndDate.')</font><br/>'.$sDescription.'';
}
}
}

which is pulling out discount codes for one store, the store is defined by this piece of code.

'iMerchantId' => array(1599)

but what i want to try and achieve is to receive discount codes from an array of stores, which i cannot get to work :(

here is the code i have tried to get all the codes from all the stores

$storesArray = array(
9,15,65,172,323,380,483,547,550,686,782,854,896,911,980,
1052,1084,1107,1109,1132,1134,1184,1186,1198,1202,1221,1228,
1256,1257,1270,1311,1322,1331,1350,1402,1404,1418,1472,1487,
1521,1559,1597,1598,1599,1672,1744,1815,1826,1836,1916,1946,
1947,1964,1970,1995,2026,2038,2041,2066,2124,2147,2203,2208,
2249,2258,2276,2344,2354,2383,2424,2433,2453,2481,2487,2526,
2537,2547,2548,2549);
$stores = array('iMerchantId' => $storesArray);

$oClient = ClientFactory::getClient();
$merchantcolumns = array(sStrapline,sDescription,sLogoUrl,sDisplayUrl,sClickThroughUrl,oDiscountCode);
$singlemerchantwithcodes = array('iMerchantId' => $stores, "sColumnToReturn" => $merchantcolumns);
$oResponse= $oClient->call('getMerchant', $singlemerchantwithcodes);

$iId = $oResponse->oMerchant->iId;
$sName =$oResponse->oMerchant->sName;
$sStrapline = $oResponse->oMerchant->sStrapline;
$sDescription = $oResponse->oMerchant->sDescription;
$sLogoUrl = $oResponse->oMerchant->sLogoUrl;
$sDisplayUrl = $oResponse->oMerchant->sDisplayUrl;
$sClickThroughUrl = $oResponse->oMerchant->sClickThroughUrl;
echo '<a href="'.$sClickThroughUrl.'" title="'.$sName.'">'.$sName.'</a><br/>'.$sStrapline.'<br/><img src="'.$sLogoUrl.'" alt="'.$sName.'" /><br/>'.$sDescription.'';
$arraycheck1 = $oResponse->oMerchant->oDiscountCode;
if(!empty($arraycheck1))
{
echo '<div style="margin: 5px 0; background: #D5D5D5; line-height: 0; height: 1px;"></div>
<h3>Vouchers for '.$sName.'</h3>';
foreach($oResponse->oMerchant->oDiscountCode as $key=>$details2)
{
$sCode = $details2->sCode;
$sDescription = $details2->sDescription;
$sUrl = $details2->sUrl;
$sEndDate = $details2->sEndDate;

if ($sUrl<>'')
{
echo '<div style="margin: 5px 0; background: #D5D5D5; line-height: 0;
height: 1px;"></div><a href="'.$sUrl.'" title="'.$sName.'"><img src="'
.$sLogoUrl.'" alt="'.$sName.'" border="0"/></a><br><b>Voucher Code:
<a href="'.$sUrl.'">'.$sCode.'</a></b><br/> <font color="red">(Expires '
.$sEndDate.')</font><br/>'.$sDescription.'';
}
}
}

i have also tried to add the store ids like so

'iMerchantId' => array(9,15,65,172)

but this doesnt work.

im getting

Notice: Trying to get property of non-object on line 33,34,35,36,37,38,39,41

can anyone help me to get this to work?

many thanks
Luke



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum