cancel
Showing results for 
Search instead for 
Did you mean: 

Disable shipping address on one page checkout based on Shipping Methods enabled

SOLVED

Disable shipping address on one page checkout based on Shipping Methods enabled

Hi there

 

I hope someone can help.

 

I'd like to know the PHP code to check whether a particular shipping method is enabled.

 

To explain further...

 

1. I have a multistore magento site which uses the Table Rates shipping method and a 'Collect in Store' shipping method module.

2. The shipping methods vary from store to store, so on one store, only table rates may be enabled, on another store, 'Collect in store' may only be enabled, sometimes both are enabled.

3. For those stores where ONLY 'Collect in Store' is enabled, on the one page checkout I would like to skip the 'Shipping Information' stage so that the customer cannot get confused and fill in their own details. After they have filled out their billing information, the only radio button available to them is the Collect in Store one.

 

So far I have added / amended  the following:

<?php if ($this->canShip()): ?>
    	<?php  if (Mage::getConfig()->getModuleConfig('Pook_CollectInStore')->is('active', 'true')):?>
        
    	<li class="control"><input type="hidden" name="billing[use_for_shipping]" value="0" /></li>
        
        <?php else:?>
       <li class="control">
            <input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1"<?php if ($this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo  $this->__('Ship to this address') ?>" onclick="$('shipping:same_as_billing').checked = true;" class="radio" /><label for="billing:use_for_shipping_yes"><?php echo  $this->__('Ship to this address') ?></label></li>
        <li class="control">
            <input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_no" value="0"<?php if (!$this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo $this->__('Ship to different address') ?>" onclick="$('shipping:same_as_billing').checked = false;" class="radio" /><label for="billing:use_for_shipping_no"><?php echo $this->__('Ship to different address') ?></label>
        </li>
        <?php endif; ?>
        
    <?php endif; ?>

This is within app/design/frontend/rwd/theme/template/persistent/checkout/onepage/billing.phtml

 

This is almost doing what I need it to do, except it is checking whether that module is enabled globally, when really, I just need it to check if it's enabled as a shipping method for the store.

 

I think if I can check whether collect in store is enabled as a shipping method, and table rates is disabled, then I'll be able to make this work.

 

Is there a way to do this? Thanks in advance.

 

5 REPLIES

Re: Disable shipping address on one page checkout based on Shipping Methods enabled

instead of getConfig() try getStoreConfig()

Re: Disable shipping address on one page checkout based on Shipping Methods enabled

Thank you for your reply, however that tends to break the page. Thanks anyway.

Re: Disable shipping address on one page checkout based on Shipping Methods enabled

you can check if table rate is active by

<?php if( Mage::getStoreConfigFlag('carriers/tablerate/active') ) : ?>

your custom plugin collect in store should have similar config value

BTW, the hidden field for collect in store only should be 1 instead of 0 to skip shipping address

Re: Disable shipping address on one page checkout based on Shipping Methods enabled

Hi there,

 

Thank you very much for your reply. I will give that a go and also look at the custom module and change the hidden field. Thank you very much.

Re: Disable shipping address on one page checkout based on Shipping Methods enabled

Worked a treat! Thank you very much x