php whmcs隐藏货币客户侧边栏

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php whmcs隐藏货币客户侧边栏相关的知识,希望对你有一定的参考价值。

<?php
//method 1
use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {

   global $gid;

   $content = '<form method="post"  action="cart.php?gid='.$gid.'"><select name="currency"  onchange="submit()" class="form-control"><option value="2" selected>IDR</option><option value="4">USD</option></select></form>';

   if (!is_null($secondarySidebar->getChild('Choose Currency')))
               $secondarySidebar->getChild('Choose Currency')
                               ->setBodyHtml($content);
});

/**
 * Method 2: 
 * query the database to get a list of all currencies, except USD, and then loop through the array to create the dropdown
 * If wanted to remove the dropdown, adjusting the content of $content by removing the form and adding links and images
*/
use WHMCS\View\Menu\Item as MenuItem;
use Illuminate\Database\Capsule\Manager as Capsule;

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {

   $currencies = Capsule::table('tblcurrencies')
               ->where('code', '!=', 'USD')
               ->get();

   $content = '<form method="post" action="cart.php?'.$_SERVER["QUERY_STRING"].'">
   <select name="currency" onchange="submit()" class="form-control">';
   $mycurrency=$_POST['currency'];
   foreach ($currencies as $currency) {
       $content .= '<option value="'.$currency->id.'"';
           if ($mycurrency==$currency->id) {
               $content .= ' selected';
           }
       $content .= '>'.$currency->code.'</option>';
   }
   $content .= '</select></form>';

   if (!is_null($secondarySidebar->getChild('Choose Currency')))
               $secondarySidebar->getChild('Choose Currency')
                               ->setBodyHtml($content);
});

/**
 * for Smarty code
*/
//should display all currencies in the responsive mode dropdown apart from USD
{foreach from=$currencies item=curr}
   {if $curr.code neq 'USD'}
       <option value="{$curr.id}">{$curr.code}</option>
   {/if}
{/foreach}

以上是关于php whmcs隐藏货币客户侧边栏的主要内容,如果未能解决你的问题,请参考以下文章

如何在wordpress中实现不同页面隐藏或者显示侧边栏?

如何在用户注销时隐藏侧边栏并在用户登录时显示侧边栏?

Ag-grid:在侧边栏面板外部以角度单击时隐藏列侧边栏

如何使用一些热键隐藏标题和侧边栏

登录后隐藏侧边栏

右侧栏为0%至-100%的侧边栏无法隐藏