Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

problem with conditional code in checkout if subtotal = 0
 
warwickmc
Member
 
Total Posts:  33
Joined:  2008-07-14
 

hi everyone, need a little help, im new to php and magento and im trying to get this bit of code to work, basically what i want it to do is if subtotal = 0 it skips the payment method step, in a similar fashion to the way it skips the shipping method step if its a virtual product. As best i could tell the saveBillingAction() function is where its at, although i havent figured out how the virtual product property removes the step entirely from the checkout, if anyone could point that out to me it would be great. Here is my code for saveBillingAction() so far.

public function saveBillingAction()
    
{
        $this
->_expireAjax();
        if (
$this->getRequest()->isPost()) {
            $data 
$this->getRequest()->getPost('billing', array());
            
$customerAddressId $this->getRequest()->getPost('billing_address_id'false);
            
$result $this->getOnepage()->saveBilling($data$customerAddressId);
            
$subtotal Mage::getModel('sales/quote')->load(Mage::getSingleton('checkout/session')->getQuoteId())->getBaseSubtotal();
            

            
            
            if (!isset(
$result['error'])) {
                
/*check subtotal for amount*/
                
if ($subtotal == '0')
                
{
                $this
->getOnepage()->savePayment('free');

                
$result['goto_section''review';
                
$result['update_section'= array(
                    
'name' => 'review',
                    
'html' => $this->getLayout()->getBlock('root')->toHtml()
                );

                  
}
                
/* check quote for virtual */
                
if ($this->getOnepage()->getQuote()->isVirtual()) {
                    $result[
'goto_section''payment';
                    
$result['update_section'= array(
                        
'name' => 'payment-method',
                        
'html' => $this->_getPaymentMethodsHtml()
                    );
                
}
                
elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'== 1{

                   $result[
'goto_section''shipping_method';

                    
$result['update_section'= array(
                        
'name' => 'shipping-method',
                        
'html' => $this->_getShippingMethodsHtml()
                    );

                    
$result['allow_sections'= array('shipping');
                    
$result['duplicateBillingInfo''true';
                
}
                
else {
                    $result[
'goto_section''shipping';
                
}
            }

As you can see ive added an addition to the if statement to check for subtotal amount, but all the code does if executed from there is nothing after the billing details page, you can click the button just nothing happens. would anyone happen to have a way to debug those code errors in-browser? also would be a time-saving thing to have. Any help would be most appreciated. Please note, i am well aware that my code could be WAAAAY out, its been a fair bit of guess work up until now.

 
Magento Community Magento Community
Magento Community
Magento Community
 
warwickmc
Member
 
Total Posts:  33
Joined:  2008-07-14
 

just bumping this one, im really stuck trying to find a solution, any clues??? anyone???

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top