Order form - how to replace carrier/payment choosing to a constant value

mnbg

Avatar: mnbg

2008-07-08 21:33

Hi,

I have a question regarding the Carrier/Payment in the Order form in Quick.Cart.
In our business we only have one (1) carrier/payment choice, and the customer should not be able to select any alternative.
Is it possible to hide/remove the Carrier/Payment module in the Order form and just add a standard delivery cost to the order?
Best regards,
Magnus

» Quick.Cart v3.x

Magnus

Makaron

Avatar: Makaron

2008-07-09 10:52

I solve this problem but it's little complicated to give instructions step by step but I will try..

Step 1)
Firstly in file config/general.php somewhere near another declaration like "$config['login'] = "admin";" add this two lines:

$config['delivery'] = 100;
define'DELIVERY'$config['delivery'] );


Of course You have to declare here Your own price of delivery (in my example it equals 100).

Step 2)
Edit file core/orders.php. I made some modifications in listProducts function so I paste here whole function:

  /**
  * List products in basket
  * @return string
  * @param string $sFile
  * @param int    $iId
  * @param string $sBlock
  */
  
function listProducts$sFile$iId null$sBlock null ){
    
$oTpl =& TplParser::getInstance( );
    
$content null;

    if( !isset( 
$this->aProducts ) ){
      if( !isset( 
$iId ) ){
        
$this->generateBasket( );
      }
      else{
        
$this->generateProducts$iId );
      }
    }

    if( !isset( 
$sBlock ) )
      
$sBlock 'BASKET_';

    
$fSummary 0;

    if( isset( 
$this->aProducts ) ){
      
$i 0;
      
$iCount count$this->aProducts );
      foreach( 
$this->aProducts as $aData ){
        
$aData['iStyle'] = ( $i ) ? 01;
        
$aData['sStyle'] = ( $i == ( $iCount ) ) ? 'L'$i 1;
        
$aData['sSummary'] = displayPricenormalizePrice$aData['fSummary'] ) );
        
$aData['sPrice'] = displayPrice$aData['fPrice'] );
        
$aData['sLinkDelete'] = defined'CUSTOMER_PAGE' ) ? $GLOBALS['aData']['sLinkName'].'&iProductDelete='.$aData['iProduct'] : null;
        
$oTpl->setVariables'aData'$aData );
        
$fSummary += $aData['fSummary'];
        
$content .= $oTpl->tbHtml$sFile$sBlock.'LIST' );
        
$i++;
      }

      
$aData['fDelivery'] = normalizePriceDELIVERY );
      
$aData['fProductsSummary'] = normalizePrice$fSummary);
      
$aData['sProductsSummary'] = displayPrice$aData['fProductsSummary'] );
      
$aData['sFinalSummary'] = normalizePrice$aData['fProductsSummary'] + $aData['fDelivery'] );
      if( isset( 
$iId ) && isset( $this->aOrders[$iId] ) ){
        
$this->aOrders[$iId]['fProductsSummary'] = $aData['fProductsSummary'];
        
$this->aOrders[$iId]['fOrderSummary'] = $aData['fOrderSummary'] = normalizePrice$aData['fProductsSummary'] + $aData['fDelivery']);
        
$this->aOrders[$iId]['sOrderSummary'] = $aData['sOrderSummary'] = displayPrice$aData['fOrderSummary']);
      }

      
$oTpl->setVariables'aData'$aData );
      return 
$oTpl->tbHtml$sFile$sBlock.'HEAD' ).$content.$oTpl->tbHtml$sFile$sBlock.'FOOT' );
    }
  } 
// end function listProducts


If You haven't made any changes You can just copy it to Your file.
Also in this file in function checkFields You have to delete this lines:

    if( isset( $aForm['sPaymentCarrier'] ) ){
      
$aExp explode';'$aForm['sPaymentCarrier'] );
      if( isset( 
$aExp[0] ) && isset( $aExp[1] ) )
        
$sPrice $this->throwPaymentCarrierPrice$aExp[0], $aExp[1] );
    }


and

      && isset( $sPrice )


In function addOrder delete this lines:

$aExp explode';'$aForm['sPaymentCarrier'] );
    
$aCarrier $this->throwCarrier$aExp[0] );
    
$aPayment $this->throwPayment$aExp[1] );

    
$aForm['sCarrierName']  = $aCarrier['sName'];
    
$aForm['fCarrierPrice'] = $aCarrier['fPrice'];
    
$aForm['iCarrier']      = $aCarrier['iCarrier'];
    
$aForm['sPaymentName']  = $aPayment['sName'];
    
$aForm['iPayment']      = $aPayment['iPayment'];
    
$aForm['sPaymentPrice'] = $this->throwPaymentCarrierPrice$aExp[0], $aExp[1] );



Step 3)
In file templates/orders_form.tpl You should delete this lines:

<fieldset id="deliveryAndPayment">
      <
legend>$lang[Delivery_and_payment]</legend>
      
$sPaymentCarriers
    
</fieldset>


Also You have to replace this code:

<td id="carrierCost">
          
0.00
        
</td>


for:

<td id="carrierCost">
                  
$aData[fDelivery]
        </
td>


And replace this lines:

<td id="orderSummary">
          
$aData[sProductsSummary]
        </
td>


to

<td id="orderSummary">
          
$aData[sFinalSummary]
        </
td>



Step 4)
Finally in file templates/order_print.tpl You have to replace this:

<th colspan="3">$lang[Delivery_and_payment]: $aOrder[sCarrierName], $aOrder[sPaymentName]</th>
        <
td id="carrierCost">$aOrder[sPaymentCarrierPrice]</td>


for:

<th colspan="3">$lang[Delivery_and_payment]: $aOrder[sCarrierName]</th>
        <
td id="carrierCost">$aData[fDelivery]</td>

mnbg

Avatar: mnbg

2008-07-09 14:43

Many thanks Makaron, you are the best! Works perfectly!
Best regards,
Magnus

Magnus

beholder

Avatar: beholder

2008-07-09 14:51

BTW, in the future the QC should detect only 1 carrier and payment combination and NOT display the carrier/payment module in such case. That would be the cleanest solution for the future, just like it is done with the special pages (for example search, order form).

QC v3.0

Frans123

Avatar: Frans123

2008-08-02 10:36

Great function!

I just installed it but now my delete buttons in the cart don't work anymore.
nothing happes when I click on them.
http://img134.imageshack.us/my.php?image=deleteqd3.jpg

I just undid the whole procedure again and now they work again.

Any idea how to tweak the above function so that the delete buttons keep working?

Frans

Frans123

Avatar: Frans123

2008-08-11 19:28

nevermind my post above.
I am using the PAID version.
On the free version the above code works fine.

I just received the code for the paid version from opensolutions.

frans

gwmbox

Avatar: gwmbox

2008-08-13 03:52

Wow - I was about to do all this and then thought there must be a simpler way. I also prefer not to alter any core files as it can cause issues later when you need to upgrade.

Ok my fix was to first setup a default carrier and set it up as 0.00 price.

In order_form.tpl replace

<input type="radio" name="sPaymentCarrier" value="$aData[iCarrier];$aData[iPayment];$aData[fPaymentCarrierPrice]" onclick="countCarrierPrice( this )" alt="radio;$lang['Select_delivery_and_payment']" />$aData[sPaymentCarrierPrice]



with

<input type="radio" name="sPaymentCarrier" value="1;1;0.00" checked onClick="countCarrierPrice( this )" alt="radio;Choose delivery and payment method" />0.00



(notice it is checked)

I then add these two items to the css

#deliveryAndPayment {
display: none;
}

.summaryDelivery {
display: none;
}

Which hides the delivery and payment part and all is sweet :)

I hope this helps you :)

Augie

No avatar

2008-09-23 06:11

Sorry, here is the image link.

http://img510.imageshack.us/my.php?image=orderformyi5.jpg

Ringo

No avatar

2008-09-26 16:07

gwmbox: Your solutions is fine only for eshops with no shippings.

So I tried Makaron's method. It is working, but carrier and payment prices are missing in order administration and in sent emails.

Any simple solution?

chivas

Avatar: chivas

2008-12-24 14:28

The solution from gwmbox works nice.
This is, if you use only one type of carrier and payment.

Thanks!

Geert Bouckaert - Belgium

tarok

No avatar

2009-02-16 14:54

thank you!

mortismortef

Avatar: mortismortef

2009-02-27 22:20

thank you! thank you! thank you! thank you! thank you! thank you!

beholder

Avatar: beholder

2009-03-07 01:50

hey guys, notice that gwmbox'es solution doesn't actually allow the shipping to have a price.
On the other hand, here is a perfect way to have only one carrier/payment preselected and still to be able to set their price in a normal way, via administration. The shipping price (payment/courier) is correctly displayed in order form and finished order as well as email to admin/customer:

1. First make sure you have only ONE carrer and only ONE payment.


2. Then in templates/orders_form.tpl add checked="checked" id="carrierprice" to block ORDER_PAYMENT_CARRIERS_LIST, like this:


<!-- BEGIN ORDER_PAYMENT_CARRIERS_LIST -->
<
td><input type="radio" checked="checked" id="carrierprice" name="sPaymentCarrier" value="$aData[iCarrier];$aData[iPayment];$aData[fPaymentCarrierPrice]" onclick="countCarrierPrice( this )" alt="radio;$lang['Select_delivery_and_payment']" />$aData[sPaymentCarrierPrice]</td>
<!-- 
END ORDER_PAYMENT_CARRIERS_LIST -->




3. then in the same file add following javascript section before the end of block ORDER_FORM, after last </div>:


<script type="text/javascript">
<!--
countCarrierPricegEBI'carrierprice' ) );
  
//-->
</script>




4. the last step is optional, if you want to completely hide the delivery and payment table, just add style="display: none;" to fieldset deliveryAndPayment, like this:
<fieldset id="deliveryAndPayment" style="display: none;">

Hopefully I didn't make any mistake, someone please test and report here.

about us | contact