Aethelwulf
Member
I've spent the past few hours dabling into creating a custom xenforo user upgrade page based off of the actual user upgrade page. So far I've been able to customize the UserUpgrade page by tweaking it to begin creating a tiered perm. payment model but now I want to put the account upgrade on its own page node.
I've been following one of the video tutorials posted on here, taking from what they've done, I've created a php class and function that calls the XenForo_Model_UserUpgrade but the way I'm doing this is obviously wrong. With so many arrays buried in another array and then burried in another array after that, it gets a bit.. well.. errm. Could someone maybe tell me what I would need to call to get the upgrade model to display correctly with the template file posted below?
*Edit* I think I've got it.
Template for seperate Account Upgrade. Just a copy/paste from the account_upgrade template.
I've been following one of the video tutorials posted on here, taking from what they've done, I've created a php class and function that calls the XenForo_Model_UserUpgrade but the way I'm doing this is obviously wrong. With so many arrays buried in another array and then burried in another array after that, it gets a bit.. well.. errm. Could someone maybe tell me what I would need to call to get the upgrade model to display correctly with the template file posted below?
*Edit* I think I've got it.
Code:
class Dev_PurchasePage extends XenForo_Model
{
public static function respond(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract $response)
{
$upgradeModel = $controller->getModelFromCache('XenForo_Model_UserUpgrade');
$response->params['payPalUrl'] = 'https://www.paypal.com/cgi-bin/webscr';
$response->params['available'] = $upgradeModel->prepareUserUpgrades($purchaseList['available']);
$response->params['purchased'] = $upgradeModel->prepareUserUpgrades($purchaseList['purchased']);
$response->templateName = 'purchase';
}
}
Template for seperate Account Upgrade. Just a copy/paste from the account_upgrade template.
Code:
<xen:title>{xen:phrase account_upgrades}</xen:title>
<xen:require css="account_upgrades.css" />
<xen:if is="{$available}">
<div class="section">
<h3 class="subHeading">{xen:phrase available_upgrades}</h3>
<ul>
<li class="primaryContent upgrade"><div class="cost"></div>
<div class="upgradeMain"><b>Account upgrades are tiered. If you purchase one upgrade now and wish to purchase another later,
you will only ever have to pay the difference between the two. </b><br />
</div></li>
<xen:foreach loop="$available" value="$upgrade">
<li class="primaryContent upgrade">
<form action="{$payPalUrl}" method="post" class="upgradeForm">
<div class="cost">
<xen:if is="{$upgrade.costPhraseBeforeDiscount}">
Standard Price: <span style="color:#a1a1a1; text-decoration:line-through; font-style:italic;">{$upgrade.costPhraseBeforeDiscount}</span> <br />
Your Price: <b></xen:if>
{$upgrade.costPhrase}<xen:if is="{$upgrade.costPhraseBeforeDiscount}"></b></xen:if>
</div>
<xen:if is="{$upgrade.length_unit} AND {$upgrade.recurring}">
<input type="hidden" name="cmd" value="_xclick-subscriptions" />
<input type="hidden" name="a3" value="{$upgrade.cost_amount}" />
<input type="hidden" name="p3" value="{$upgrade.length_amount}" />
<input type="hidden" name="t3" value="{$upgrade.lengthUnitPP}" />
<input type="hidden" name="src" value="1" />
<input type="hidden" name="sra" value="1" />
<input type="submit" value="{xen:phrase subscribe}" class="button" />
<xen:else />
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="amount" value="{$upgrade.cost_amount}" />
<input type="submit" value="{xen:phrase purchase}" class="button" />
</xen:if>
<input type="hidden" name="business" value="{$xenOptions.payPalPrimaryAccount}" />
<input type="hidden" name="currency_code" value="{$upgrade.currency}" />
<input type="hidden" name="item_name" value="{xen:phrase account_upgrade}: {$upgrade.title} ({$visitor.username})" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="custom" value="{$visitor.user_id},{$upgrade.user_upgrade_id},token,{$visitor.csrf_token_page}" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="email" value="{$visitor.email}" />
<input type="hidden" name="return" value="{$requestPaths.fullBasePath}{xen:link account/upgrade-purchase}" />
<input type="hidden" name="cancel_return" value="{$requestPaths.fullBasePath}{xen:link index}" />
<input type="hidden" name="notify_url" value="{$xenOptions.boardUrl}/payment_callback.php" />
</form>
<div class="upgradeMain">
<h4 class="title">{$upgrade.title}</h4>
<xen:if is="{$upgrade.description}">
<div class="description">{xen:raw $upgrade.description}</div>
</xen:if>
</div>
</li>
</xen:foreach>
</ul>
</div>
</xen:if>
<xen:if is="{$purchased}">
<div class="section">
<h3 class="subHeading">{xen:phrase purchased_upgrades}</h3>
<ul>
<xen:foreach loop="$purchased" value="$upgrade">
<li class="primaryContent">
<div class="upgrade">
<div class="upgradeForm">
<xen:if is="{$upgrade.record.end_date}">
<div>{xen:phrase expires}: <xen:datetime time="$upgrade.record.end_date" /></div>
</xen:if>
<xen:if is="{$upgrade.length_unit} AND {$upgrade.recurring}">
<a href="{$payPalUrl}?cmd=_subscr-find&alias={xen:urlencode $xenOptions.payPalPrimaryAccount}" class="button">{xen:phrase cancel_subscription}</a>
</xen:if>
</div>
<div class="upgradeMain">
<h4 class="title">{$upgrade.title}</h4>
<xen:if is="{$upgrade.description}">
<div class="description">{xen:raw $upgrade.description}</div>
</xen:if>
</div>
</div>
</li>
</xen:foreach>
</ul>
</div>
</xen:if>
Last edited: