Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Free Shipping Warning Addon Help Rate Topic   - - - - -

 
  • Jmoffat
  • Member
  • Members
  • Join Date: 15-Oct 12
  • 39 posts

Posted 20 May 2016 - 02:29 PM #1

Hi everyone

 

I'm new to programming for cs cart and was hoping to get some help on creating a custom addon. It's mostly a learning project but also a useful feature on the cart. 

 

I'd like to display a box at the checkout which warns the customer when their order subtotal is almost high enough for them to receive free shipping. like so: 

 

freeshipping%20addon.JPG

 

So far I've achieved this by using a template hook: summary.override.tpl with the following code:

{assign var="sub_total" value=$cart.display_subtotal-$tax.tax_subtotal}
{assign var="remaining" value=50-$sub_total}
{if $remaining>0 && $remaining<20}
<div style="border:1px solid red; padding: 5px;text-align:center;">
<p style="color:red;font-size: 16px;"><strong>You're almost eligible for free shipping!</strong></p>
    <p style="color:red;font-size: 14px;">Spend just {$remaining|format_price:$currencies.$secondary_currency:$span_id:$class:true:$is_integer:$live_editor_name:$live_editor_phrase nofilter} more to receive free shipping.*</p>
</div>
<p style="font-size: 12px;">*order must be over £50 before adding VAT.</p>
{/if}

At the moment the order subtotals between which the message should be shown are hard coded into the template. The above code will show the message if the order subtotal is greater than £30 but below £50. customers receive free shipping on orders over £50 so no need to show the message if the subtotal is higher than this. 

 

I'd like to make this more flexible by create fields in the addon settings where custom values can be input and having the cart use those rather than having to code the values into the template. 

 

so far I've gotten as far as this in the addon.xml file:

<?xml version="1.0"?><addon scheme="2.0">
    <id>shipping_note</id>
    <name>Free Shipping Warning</name>
    <description>Shows message when customer is close to threshold for free shipping</description>
    <version>1.0</version>
    <priority>10000000</priority> <position>0</position>
<status>active</status>
    <auto_install>MULTIVENDOR,ULTIMATE</auto_install>
    <default_language>en</default_language>


<queries>
        <item for="install">DROP TABLE IF EXISTS ?:shipping_note_data;</item>
<item for="install">
            CREATE TABLE `?:shipping_note_data` (
`ship_thresh` int(11) unsigned NOT NULL DEFAULT 0,
`mess_thresh` int(11) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`ship_thresh`)
) Engine=MyISAM DEFAULT CHARSET UTF8;
</item>
        <item for="uninstall">DROP TABLE IF EXISTS ?:shipping_note_data;</item>
</queries>


<settings> <sections> <section id="general">
<items>
<item id="ship_thresh">
<name>Free Shipping Threshold</name>
<type>input</type>
</item>
<item id="mess_thresh">
<name>Show Message at</name>
<type>input</type>
</item>
</items></section></sections></settings>
</addon>

On installation the addon creates a new table in the database with a column each for the free shipping threshold (the order subtotal after which the customer will receive free shipping) and the message threshold (the minimum order subtotal needed before the message is shown). 

 

My questions are.

How do I have the addon upload the values in the addon's setting fields into the table on the database?

How do I then retrieve these values from the database for use on the template files?

 

Sorry if this is super basic. If someone could point me in the right direction that would be a great help.

 

Thanks in advance!

 



 
  • The Tool
  • Been Here Way Too Long Member
  • Members
  • Join Date: 30-Mar 07
  • 3752 posts

Posted 20 May 2016 - 02:41 PM #2

There is already a couple of these in the marketplace if that helps any.?  The first one is free.

 

http://marketplace.c...ier-add-on.html

http://marketplace.c...or-cs-cart.html



 
  • Jmoffat
  • Member
  • Members
  • Join Date: 15-Oct 12
  • 39 posts

Posted 20 May 2016 - 02:46 PM #3

There is already a couple of these in the marketplace if that helps any.?  The first one is free.

 

http://marketplace.c...ier-add-on.html

http://marketplace.c...or-cs-cart.html

 

Great thanks. I'll download the first one and see how they do it. 



 
  • akistdm
  • Senior Member
  • Trial users
  • Join Date: 09-Oct 11
  • 229 posts

Posted 22 May 2016 - 12:57 PM #4

these two are great addon but the firts one i tried dosn't seem to work with the category restrictions.

So if you have a category that you don't want to give free shipping, you can not exlude it.