VirtueMart 2 + 3 > Templating & Layouts

Cart Page Fields & Modifications

(1/24) > >>

PRO:
Here are some fields for modifying the cart page to make it more user friendly.

I use these fields to make my own "checkout steps"

<?php if (empty($this->cart->BT)){ ?> What you put here will be shown when NO billing address is completed<?php }?>

<?php if (!empty($this->cart->BT)){ ?> This shows AFTER the billing Address is completed <?php }?>

<?php if ($this->cart->cartData['paymentName'] == 'No payment selected') {?> This shows when the payment has NOT been selected<?php }?>
^^^ "No payment selected" is English, so change it to suit your language

<?php if ($this->cart->cartData['paymentName'] != 'No payment selected') {?> AFTER Payment Has Been Selected<?php }?>
^^ Same language applies here.


This code will change the text from "Add Your Billing" to Edit Your Billing, if the billing is already filled in.
      <?php if (empty($this->cart->BT)){ ?>
      <a class="details bold font14 m4" href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=BT',$this->useXHTML,$this->useSSL) ?>">
      Add Your Billing Address
      </a>   <?php } ?>
<?php if (!empty($this->cart->BT)){ ?>
      <a class="details bold font14 m4" href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=BT',$this->useXHTML,$this->useSSL) ?>">
      Edit Your Billing Address
      </a>   <?php } ?>

This Code will display "Shipping to a Different Address?"  when the billing is filled in, but NOT the shipping.

      <?php if ((!empty($this->cart->BT)) && (empty($this->cart->ST))){ ?>
      <a class="details bold font14 m4" href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=ST&virtuemart_user_id[]='.$this->cart->lists['current_id'],$this->useXHTML,$this->useSSL) ?>">
      Shipping to a different address? </a><?php } ?>

Displays "Edit Your Shipping Address" When its already filled in

      <?php if(!empty($this->cart->STaddress['fields'])){ ?>
      <a class="details bold font14 m4" href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=ST&virtuemart_user_id[]='.$this->cart->lists['current_id'],$this->useXHTML,$this->useSSL) ?>">
      Edit Your Shipping Address
      </a> <?php }?>


A couple ways of NOT displaying taxes & calculation rules when billing address is not filled in. BUT, the total will include the tax amount, but can also be wrapped.

<?php if (!empty($this->cart->BT)){ ?>
WRAP the calculation in this code
?>

OR: You can set the rule to 0 , if no billing address is filled in.

<?php foreach($this->cart->cartData['taxRulesBill'] as $rule){ ?>
      <?php if (empty($this->cart->BT)){ $rule=Null;}?>
         <tr class="sectiontableentry<?php $i ?>">
            <td colspan="4" align="right"><?php echo $rule['calc_name'] ?> </td>
            <?php if ( VmConfig::get('show_tax')) { ?>
            <td align="right"><?php echo $this->currencyDisplay->createPriceDiv($rule['virtuemart_calc_id'].'Diff','', $this->cart->pricesUnformatted[$rule['virtuemart_calc_id'].'Diff'],false); ?> </td>
             <?php } ?>
            <td align="right"><?php ?> </td>
            <td align="right"><?php echo $this->currencyDisplay->createPriceDiv($rule['virtuemart_calc_id'].'Diff','', $this->cart->pricesUnformatted[$rule['virtuemart_calc_id'].'Diff'],false); ?> </td>
         </tr>
         <?php
         if($i) $i=1; else $i=0;
      }
 ?>

This code <?php if (empty($this->cart->BT)){ $rule=Null;}?>   sets the rule to Null if the billing is not filled in



If the billing address is not filled in, you can subtract the tax from the total. To show the total without tax.
<?php if (empty($this->cart->BT)){$this->cart->pricesUnformatted['billTotal']=$this->cart->pricesUnformatted['billTotal']-$this->cart->pricesUnformatted['billTaxAmount'];}?> <?php echo $this->currencyDisplay->createPriceDiv('billTotal','', $this->cart->pricesUnformatted['billTotal'],false); ?>

THIS code will display the "Confirm order button" where you want it. ONLY when the billing & payment has been filled in
<?php if ((!empty($this->cart->BT))&& ($this->cart->cartData['paymentName'] != 'No payment selected') ){
 echo '<h1 class="bottom10 border" style="width:180px;">';
         echo $this->checkout_link_html;
         $text = JText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
         echo '</h1>';

}?>

Same code as above, but checks if "terms of service are checked"
<?php if (((!empty($this->cart->BT))&& ($this->cart->cartData['paymentName'] != 'No payment selected') )&& ($this->cart->tosAccepted)){
 echo '<h1 class="bottom10 border" style="width:180px;">';
         echo $this->checkout_link_html;
         $text = JText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
         echo '</h1>';



Choose Payment Page
Auto select payment method.
http://forum.virtuemart.net/index.php?topic=108974


UPDATED::: still working
Code below will be for improvements while using the native "1 page checkout" 

To hide the payment form when a payment has already been set. It will also display the "edit payment" link

cart/default_pricelist.php
change this
<?php if (!empty($this->layoutName) && $this->layoutName == 'default') {
if (VmConfig::get('oncheckout_opc', 0))) {

to this
<?php if (!empty($this->layoutName) && $this->layoutName == 'default') {
if ((VmConfig::get('oncheckout_opc', 0))&& ($this->cart->cartData['paymentName'] == 'No payment selected')) {

I was getting problems with checking for billing address when default country is set.
So I wrote this function

<?php function valBT($items){
      foreach($items['fields'] as $item){
      if ($item['name']!='address_1') continue;
      if ($item['name']=='address_1' && !empty($item['value']) ){return true;}
      else return false;
      }} ?>

Then you can check if the billing is empty like this
<?php if (!valBT($this->cart->BTaddress)){ ?>This is when it is empty<?php }?>
& when it is not empty
<?php if (valBT($this->cart->BTaddress)){ ?>This is when billing is filled in <?php }?>

You can also use this native function to test if all is filled in, billing, shipment method, and payment method
<?php  if ($this->cart->getDataValidated()){ ?> This is when its all selected <?php }?>
or
<?php  if (!$this->cart->getDataValidated()){ ?> This is when it's missing something<?php }?>

Test if the billing & shipping address is the same
<?php if ($this->cart->ST==$this->cart->BT) { ?> This is when they are the same <?php } ?>

or if different
<?php if ($this->cart->ST!=$this->cart->BT) { ?> This is when they are the same <?php } ?>












Ffragrances:


You seem to have an excellent grasp on the PHP required to make very important corrections on the cart page. I would say this would cross over to just about any other page as well, as long as you  know what and where the "params" are. I was wondering if you might be kind enough to assist me with this one. I am just learning PHP and some Javascript, but slowly as I am very busy with many other things.

I have a test upgrade site that I am close to finishing in a sub directory while my old site runs live until I can finally get this one dialed in. Here is what I am trying to do.

I migrated the old site to the latest versions of both Joomla 2.5 and VM2. Server PHP 5.3+. I have purchased the USPS module that was developed by members of the VM team and it seems to be functioning well. I also setup, as I was advised to do, the generic shipping module for free shipping which also works, except that the customer still has too go to the select shipment page in order to select the Free Shipping option. In previous versions of VM the core setup under Shop Configuration had the option to set up free shipping and so no matter what modules you run, or how many (I have 3 total), the core would automatically halt the output of the other modules and auto select the Free Shipping option for the customer once they had purchased the correct preset amount of product. I will also have a copy of the generic shipping module setup just to list Local Pick or Delivery for my local customers in my zip code to select.

It seems that is not possible with the current version unless the output of all but the free module setup is running. So, the USPS module does not have a Max. dollar amount param. that you can set so the auto function will not work. So yes the customer can indeed go to the next page and select free shipping, but I would like to make it at least echo some text in the cart that their order now qualified for the free shipping, and if they would please go and select it, since I cannot set it to auto select until either the developers add that older function to VM2, or they add a max param. to the USPS module to stop it's output when that max is met, and leaving the other remaining module to be auto selected by VM2's core settings.

So essentially I need an IF "freeshipping" is active, echo or post the a message on the cart that their "Order Has Qualified for Free Shipping but need to select it", so as to cut back on any confusion and potential loss of business when people do not see the Free Shipping immediately and decide to just leave the cart and the site.

I have a basic understanding of what your code means and how it works but not exactly where or what "params" to use etc.. I thought you might be kind enough to share your more advanced knowledge and help a brother out... It never hurts to ask.

Current setup:

Shipping Modules;


USPS Module Settings;


Free Shipping Module Settings;


Current Cart Summary Output;


What I would like to get until maybe someone fixes the core code or makes additional code changes to the plugins;


Gave as much detail as I thought someone might need. Hopefully you or someone will be kind enough to assist or point me in the right direction to repair this missing setup feature form the older version of VM.

Thanks in advance, :)

PRO:
<?php if ($this->cart->pricesUnformatted['salesPrice']>=60){echo 'Your Order Qualifies for Free Shipping';}?>

szbstvn:
It s great!

I would like the BT and ST address add/mod on the cart page but without button! Only two form and the shoppers can save these data togheter with all page. This way maybe easier than click to buttons step the other page and back.

Somebody can help me?

Ffragrances:

--- Quote from: PRO on October 10, 2012, 17:18:40 pm ---<?php if ($this->cart->pricesUnformatted['salesPrice']>=60){echo 'Your Order Qualifies for Free Shipping';}?>

--- End quote ---

That is awesome, and worked great! Thank you so much. SO now I just have to get rid of that text once they have selected the Free Shipping. So far I have tried this, but I believe I am using it incorrectly:

I put this in the line below the code that you gave me to use...

<?php if ($this->cart->cartData['shipmentName']=='Free Shipping')echo str_replace("Your Order Qualifies for Free Shipping. Please Select Free Shipping using the link on the left."," ","Your Order Qualifies for Free Shipping. Please Select Free Shipping using the link on the left.") ?>

Of course it is not working.. LOL. Or should I use something like this in the default.php instead of the default_pricelist.php. I guess I am looking to scan the page for that string of text and remove it. I am trying to learn slowly. Working on this is helping me pick up on a few things. Especially when breaking down what code snippets you have provided. One day I will learn all of this.... :)

 I also tried this  to test but it of course does not work either. Obviously I am a bit off here.. hmmmm ...LOL

<?php
 $oldphrase = "Your Order Qualifies for Free Shipping. Please Select Free Shipping using the link on the left";
$newphrase = ("Test");
                if ($this->cart->cartData['shipmentName']=='Free Shipping') echo str_replace($oldphrase,$newphrase,$oldphrase) ?>

Navigation

[0] Message Index

[#] Next page

Go to full version