• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

My Monkey Do

A Log of Coding Solutions

  • Home
  • Web Hosts
  • Tools
  • About

php

LemonStand eCommerce Notes

November 22, 2011 by Webhead

Lemonstand is an eCommerce solution that lets you try before you buy.  It is very simple to use and virtually no learning curve to develop for.  It uses PHP and mySQL.  Check it out for yourself here.

Below are just a bunch of notes I jotted down while using and developing for Lemonstand.

Docs are located here:  http://lemonstandapp.com/docs/api_function_and_class_reference/
http://lemonstandapp.com/docs/developer_s_guide/

Editor buttons are editable in:

System/Settings/HTML Editor Settings

 

Enabling file-based tempaltes

  1. create an empty directory on the server – not web accessible, php writable
  2. Enable file-based templates on the System/Settings/CMS Settings page.

@font-face

If you need extra file extensions for fonts to be accessible, you need to edit the .htaccess file.
http://forum.lemonstandapp.com/topic/760-font-face/page__p__3768__hl__fonts__fromsearch__1#entry3768

 

Global Content

http://forum.lemonstandapp.com/topic/2392-global-editable-region-how-to/page__p__11010__hl__%2Bpartial+%2Bcontent_block__fromsearch__1#entry11010

 

 

 

 

Filed Under: Off the Shelf Tagged With: eCommerce, mysql, php

PHP money_format for Windows

October 19, 2011 by Webhead

Problem:

I wanted to display money using the money_format.  It’s so simple to use, but it doesn’t work on Windows platform.

 

Solution:

The solution is really in the PHP manual comments.  Someone posted their solution to do money formatting manually.  I’ll repost here for convenience with an extra function check.  I also commented out a line so i don’t get a “USD” string in front of the number.

if ( ! function_exists( 'money_format' ) ) {
    /* 
    That it is an implementation of the function money_format for the 
    platforms that do not it bear.  

    The function accepts to same string of format accepts for the 
    original function of the PHP.  

    (Sorry. my writing in English is very bad)  

    The function is tested using PHP 5.1.4 in Windows XP 
    and Apache WebServer. 
    */ 
    function money_format($format, $number) 
    { 
        $regex  = '/%((?:[^!-]|+|(|=.)*)([0-9]+)?'. 
                  '(?:#([0-9]+))?(?:.([0-9]+))?([in%])/'; 
        if (setlocale(LC_MONETARY, 0) == 'C') { 
            setlocale(LC_MONETARY, ''); 
        } 
        $locale = localeconv(); 
        preg_match_all($regex, $format, $matches, PREG_SET_ORDER); 
        foreach ($matches as $fmatch) { 
            $value = floatval($number); 
            $flags = array( 
                'fillchar'  => preg_match('/=(.)/', $fmatch[1], $match) ? 
                               $match[1] : ' ', 
                'nogroup'   => preg_match('/^/', $fmatch[1]) > 0, 
                'usesignal' => preg_match('/+|(/', $fmatch[1], $match) ? 
                               $match[0] : '+', 
                'nosimbol'  => preg_match('/!/', $fmatch[1]) > 0, 
                'isleft'    => preg_match('/-/', $fmatch[1]) > 0 
            ); 
            $width      = trim($fmatch[2]) ? (int)$fmatch[2] : 0; 
            $left       = trim($fmatch[3]) ? (int)$fmatch[3] : 0; 
            $right      = trim($fmatch[4]) ? (int)$fmatch[4] : $locale['int_frac_digits']; 
            $conversion = $fmatch[5]; 

            $positive = true; 
            if ($value < 0) {                  $positive = false;                  $value  *= -1;              }              $letter = $positive ? 'p' : 'n';              $prefix = $suffix = $cprefix = $csuffix = $signal = '';              $signal = $positive ? $locale['positive_sign'] : $locale['negative_sign'];              switch (true) {                  case $locale["{$letter}_sign_posn"] == 1 && $flags['usesignal'] == '+':                      $prefix = $signal;                      break;                  case $locale["{$letter}_sign_posn"] == 2 && $flags['usesignal'] == '+':                      $suffix = $signal;                      break;                  case $locale["{$letter}_sign_posn"] == 3 && $flags['usesignal'] == '+':                      $cprefix = $signal;                      break;                  case $locale["{$letter}_sign_posn"] == 4 && $flags['usesignal'] == '+':                      $csuffix = $signal;                      break;                  case $flags['usesignal'] == '(':                  case $locale["{$letter}_sign_posn"] == 0:                      $prefix = '(';                      $suffix = ')';                      break;              }              if (!$flags['nosimbol']) {                  $currency = $cprefix .                              //($conversion == 'i' ? $locale['int_curr_symbol'] : $locale['currency_symbol']) .                              $csuffix;              } else {                  $currency = '';              }              $space  = $locale["{$letter}_sep_by_space"] ? ' ' : '';              $value = number_format($value, $right, $locale['mon_decimal_point'],                       $flags['nogroup'] ? '' : $locale['mon_thousands_sep']);              $value = @explode($locale['mon_decimal_point'], $value);              $n = strlen($prefix) + strlen($currency) + strlen($value[0]);              if ($left > 0 && $left > $n) { 
                $value[0] = str_repeat($flags['fillchar'], $left - $n) . $value[0]; 
            } 
            $value = implode($locale['mon_decimal_point'], $value); 
            if ($locale["{$letter}_cs_precedes"]) { 
                $value = $prefix . $currency . $space . $value . $suffix; 
            } else { 
                $value = $prefix . $value . $space . $currency . $suffix; 
            } 
            if ($width > 0) { 
                $value = str_pad($value, $width, $flags['fillchar'], $flags['isleft'] ? 
                         STR_PAD_RIGHT : STR_PAD_LEFT); 
            } 

            $format = str_replace($fmatch[0], $value, $format); 
        } 
        return $format; 
    } 
}

search terms used: sprintf php money

Filed Under: Coding Tagged With: php

Javascript Files with PHP

October 5, 2011 by Webhead

Below is a great article on getting your PHP to print out a javascript file and including it like any other javascript file.   You basically just have to name the file something like “something.js.php” so that PHP knows to interpret the file.  Then include it like a normal javascript file.  In the something.js.php you can add a Header() function to make it render like a javascript file (include carriage returns).

www.givegoodweb.com/post/71/javascript-php

 

 

Filed Under: Coding Tagged With: javascript, php

Mac OS X Linux Stuff

September 15, 2011 by Webhead

Locations and commands on the Mac OS X vs any other Linux/Unix system are different.  Below are some of the locations and commands I ran across in setting up my macbook as a webserver.

apache2 is located in

/etc/apache2/

Along with the httpd.conf:

/etc/apache2/httpd.conf

By default apache2 logs are located at:

/var/log/apache2

By default files in the root directory are at:

/Library/WebServer/Documents/

To restart apache:

sudo /usr/sbin/apachectl restart

or

sudo apachectl -k restart

To Enable PHP, in httpd.conf remove the ‘#’ from this line:

#LoadModule php5_module        libexec/apache2/libphp5.so

Filed Under: Server Stuff Tagged With: apache, linux, mac os x, php

eCommerce Platforms

July 23, 2011 by Webhead

I’m in the hunt for a e-commerce open source framework that is easy to use and easy to extend.  Wordpress is the perfect combination of easy to use and easy to extend.  It also has great community support.  Before WordPress I used ExponentCMS.  While that is a good CMS, it is nowhere near the level of WordPress.   I customized Exponent for a client and it did not turn out very well.   Research to find the best platform the first time around can save a lot of time, money, and headaches.  This post is from one day’s research.

 

Magento

Not Magneto, like I thought it said before I saw a YouTube video.  lol.  This open source eCommerce system is professional to say the least.  With all the options in the admin panel, it looks like you could create your ownl eBay/Amazon site.  Reviews have all been in line with it looking professional and being very flexible, but they have also said that it is overly complex and difficult to modify.  They have a lot of coding standards and very little support from the core developers on the forums.  Even experienced developers will have a hard time with it.   If the website is for a large client, this may be the one for you.  On a side note, Ebay has recently purchased Magento.

Scroll to the bottom of http://www.magentocommerce.com/demo and see the community demo.

 

Open Cart

This seems like it has almost as much features as Magento, but is praised by many as having an organized structure.  It follows the MVC (model view contoller) framework so it’s less complicated.  The ease of the framework lets it to be easier to extend.  Google insight shows that it is the most searched PHP open source eCommerce platform.

Demo here: http://www.opencart.com/index.php?route=demonstration/demonstration

 

BigCommerce ($24/month)

Upon looking at review sites I ran into some that included commercial products.  I decided to put this here because this was named the best eCommerce platform of 2011 by a couple websites.  They feature drag and drop customization of the layout and many many other features.   I haven’t done the free trial yet, but it  seems as though they got the usability and the depth right.

A video tour is available here: http://www.bigcommerce.com/ecommerce-solution-features.php

 

OsCommerce

I have heard some horrible things about this CMS including things like it’s out of date, table-based, and not modular.

 

ZenCart

I have heard that this shopping cart is based on osCommerce.  The performance and code is supposedly not very good.

 

LemonStand

From the demo, this PHP-based ecommerce solution looks easy to modify.  The templates seem like they are in a easy to understand structured format.  It does have some, although not that great, CMS capabilities.  The cost to use this is $300.   I have chosen to use LemonStand as my ecommerce solution. because of its simplicity in implementing custom themes.  They have great documentation that lets you jump in and start creating your online ecommerce solution.   I have some raw notes on lemonstand here.

 

Filed Under: Off the Shelf Tagged With: eCommerce, php

Hide WordPress Admin Bar by Default

July 21, 2011 by Webhead

Problem:

When users register for a site, they are usually just registering to comment on a page.  This means they DO NOT need the admin bar at the top hiding a portion of your page.

 

Solution:

To get rid of this  you can add this to your functions page:

 

// show admin bar only for admins and editors
if (!current_user_can('edit_posts')) {
	add_filter('show_admin_bar', '__return_false');
}

 

More solutions can be found here:

http://digwp.com/2011/04/admin-bar-tricks/

Filed Under: Coding Tagged With: php, wordpress

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 5
  • Go to page 6
  • Go to page 7
  • Go to page 8
  • Go to Next Page »

Primary Sidebar

Topics

apache apple bootstrap buddypress chrome cloudways cms css debug drupal eCommerce firebug firefox git gmail goDaddy google hosting htaccess html html 5 IE crap image iPad iPhone javascript jquery kinsta linux localization mac os x ms sql mysql open source optimize php php 7.2 svg tinymce woocommerce wordpress wpengine xss yii youtube




Categories

  • Coding
  • Off the Shelf
  • Plugins
  • Random Thoughts
  • Server Stuff
  • Tools
  • Uncategorized