function eshop_products_manager()
{
    global $wpdb, $user_ID, $eshopoptions;
    get_currentuserinfo();
    //add in if current user can here
    if (current_user_can('eShop_admin')) {
        $eshopfilter = 'all';
        if (isset($_POST['eshopfiltering'])) {
            $eshopfilter = $_POST['eshopfilter'];
        }
        ?>
		<div class="wrap">
		<div id="eshopicon" class="icon32"></div><h2><?php 
        _e('Products', 'eshop');
        ?>
</h2>
		<?php 
        eshop_admin_mode();
        ?>
		<h3><?php 
        _e('Authors', 'eshop');
        ?>
</h3>
		<?php 
        if (isset($msg)) {
            echo '<div class="updated fade"><p>' . $msg . '</p></div>';
        }
        ?>
		<form action="" method="post" class="eshop filtering">
		<p><label for="eshopfilter"><?php 
        _e('Show products for', 'eshop');
        ?>
</label><select name="eshopfilter" id="eshopfilter">
		<?php 
        echo eshop_authors($eshopfilter);
        ?>
		</select><input type="submit" name="eshopfiltering" id="submit"  class="submit button-primary" value="Filter" /></p>
		</form>
		</div>
	<?php 
    }
    ?>
	<div class="wrap">
	<h3><?php 
    _e('Products Table', 'eshop');
    ?>
</h3>
	<p><?php 
    _e('A reference table for identifying products', 'eshop');
    ?>
.</p>
	<?php 
    if (isset($_POST['eshopqp']) && isset($_POST['product'])) {
        foreach ($_POST['product'] as $id => $type) {
            $pid = $id;
            $stocktable = $wpdb->prefix . "eshop_stock";
            $eshop_product = maybe_unserialize(get_post_meta($pid, '_eshop_product', true));
            $total = 0;
            for ($i = 1; $i <= $eshopoptions['options_num']; $i++) {
                if (isset($type[$i]['stkqty']) && is_numeric($type[$i]['stkqty'])) {
                    $meta_value = $type[$i]['stkqty'];
                    $results = $wpdb->get_results("select post_id from {$stocktable} where post_id={$pid} && option_id={$i}");
                    if (!empty($results)) {
                        $wpdb->query($wpdb->prepare("UPDATE {$stocktable} set available={$meta_value} where post_id={$pid} && option_id={$i}"));
                    } else {
                        $wpdb->query($wpdb->prepare("INSERT INTO {$stocktable} (post_id,option_id,available,purchases) VALUES ({$pid},{$i},{$meta_value},0)"));
                    }
                    $total = $total + $type[$i]['stkqty'];
                }
            }
            if (isset($type['sale'])) {
                $eshop_product['sale'] = 'yes';
                update_post_meta($id, '_eshop_sale', 'yes');
            } else {
                $eshop_product['sale'] = 'no';
                delete_post_meta($id, '_eshop_sale');
            }
            if (isset($type['featured'])) {
                $eshop_product['featured'] = 'Yes';
                update_post_meta($id, '_eshop_featured', 'Yes');
            } else {
                $eshop_product['featured'] = 'no';
                delete_post_meta($id, '_eshop_featured');
            }
            if (isset($type['stkavail'])) {
                $stkav = '1';
            } else {
                $stkav = '0';
            }
            if ($stkav == '1' && ($eshop_product['description'] == '' || $eshop_product['sku'] == '' || $eshop_product['products']['1']['option'] == '' || $eshop_product['products']['1']['price'] == '')) {
                $stkav = '0';
                $emsg[0] = 'set';
            }
            if ($stkav == '1' && ($total == 0 && 'yes' == $eshopoptions['stock_control'])) {
                $stkav = '0';
                $emsg[1] = 'set';
            }
            if ($stkav == '1') {
                update_post_meta($pid, '_eshop_stock', $stkav);
            } else {
                delete_post_meta($id, '_eshop_stock');
            }
            update_post_meta($pid, '_eshop_product', $eshop_product);
        }
        $msg = '';
        if (isset($emsg)) {
            if (isset($emsg[0])) {
                $msg .= __(' Some products were marked as not available due to missing information, check the individual product pages.', 'eshop');
            }
            if (isset($emsg[1])) {
                $msg .= __(' Some products were marked as not available as no stock was found.', 'eshop');
            }
        }
        echo '<div id="message" class="updated fade">' . __('Products have been updated.', 'eshop') . $msg . "</div>\n";
    }
    //sort by switch statement
    $csa = $csb = $csc = $csd = $cse = $csf = '';
    if (isset($_GET['by'])) {
        switch ($_GET['by']) {
            case 'sa':
                //date descending
                $sortby = 'sku';
                $csa = ' class="current"';
                break;
            case 'sb':
                //description alphabetically
                $sortby = 'description';
                $csb = ' class="current"';
                break;
                /*
                	case'sc'://name alphabetically (last name)
                		$sortby='shiprate';
                		$csc=' class="current"';
                		break;
                */
            /*
            	case'sc'://name alphabetically (last name)
            		$sortby='shiprate';
            		$csc=' class="current"';
            		break;
            */
            case 'sd':
                //stock availability
                $sortby = '_stock';
                $csd = ' class="current"';
                break;
            case 'se':
                //transaction id numerically
                $sortby = '_featured';
                $cse = ' class="current"';
                break;
            case 'sf':
                //date ascending
            //date ascending
            default:
                $sortby = 'id';
                $csf = ' class="current"';
        }
    } else {
        $csf = ' class="current"';
        $sortby = 'id';
    }
    if (current_user_can('eShop_admin')) {
        if ($eshopfilter == 'all') {
            $addtoq = '';
        } elseif (is_numeric($eshopfilter)) {
            $addtoq = "AND posts.post_author = {$eshopfilter}";
        } else {
            die('There was an error');
        }
    } else {
        $addtoq = "AND posts.post_author = {$user_ID} ";
    }
    $numoptions = $eshopoptions['options_num'];
    $metatable = $wpdb->prefix . 'postmeta';
    $poststable = $wpdb->prefix . 'posts';
    $range = 10;
    $max = $wpdb->get_var("SELECT COUNT(meta.post_id) FROM {$metatable} as meta, {$poststable} as posts where meta.meta_key='_eshop_product' \r\n\tAND posts.ID = meta.post_id \r\n\tAND posts.post_status != 'trash' AND posts.post_status != 'revision'" . $addtoq);
    if ($eshopoptions['records'] != '' && is_numeric($eshopoptions['records'])) {
        $records = $eshopoptions['records'];
    } else {
        $records = '10';
    }
    if (isset($_GET['_p']) && is_numeric($_GET['_p'])) {
        $epage = $_GET['_p'];
    } else {
        $epage = '1';
    }
    if (!isset($_GET['eshopall'])) {
        $page_links = paginate_links(array('base' => add_query_arg('_p', '%#%'), 'format' => '', 'total' => ceil($max / $records), 'current' => $epage, 'type' => 'array'));
        $offset = $epage * $records - $records;
    } else {
        $page_links = paginate_links(array('base' => add_query_arg('_p', '%#%'), 'format' => '', 'total' => ceil($max / $records), 'current' => $epage, 'type' => 'array', 'show_all' => true));
        $offset = '0';
        $records = $max;
    }
    if ($max > 0) {
        $apge = get_admin_url() . 'admin.php?page=' . $_GET['page'];
        echo '<ul id="eshopsubmenu" class="stuffbox">';
        echo '<li><span>' . __('Sort Products by &raquo;', 'eshop') . '</span></li>';
        echo '<li><a href="' . $apge . '&amp;by=sf"' . $csf . '>' . __('ID Number', 'eshop') . '</a></li>';
        echo '<li><a href="' . $apge . '&amp;by=sa"' . $csa . '>' . __('Sku', 'eshop') . '</a></li>';
        echo '<li><a href="' . $apge . '&amp;by=sb"' . $csb . '>' . __('Product', 'eshop') . '</a></li>';
        // echo '<li><a href="'.$apge.'&amp;by=sc"'.$csc.'>'.__('Shipping','eshop').'</a></li>';
        echo '<li><a href="' . $apge . '&amp;by=sd"' . $csd . '>' . __('Stock', 'eshop') . '</a></li>';
        echo '<li><a href="' . $apge . '&amp;by=se"' . $cse . '>' . __('Featured', 'eshop') . '</a></li>';
        echo '</ul>';
        if (current_user_can('eShop_admin')) {
            if ($eshopfilter == 'all') {
                $addtoq = '';
            } elseif (is_numeric($eshopfilter)) {
                $addtoq = "AND posts.post_author = '{$eshopfilter}'";
            } else {
                die('There was an error');
            }
        } else {
            $addtoq = "AND posts.post_author = '{$user_ID}' ";
        }
        $myrowres = $wpdb->get_results("\r\n\t\tSELECT DISTINCT meta.post_id\r\n\t\tFROM {$metatable} as meta, {$poststable} as posts\r\n\t\tWHERE meta.meta_key = '_eshop_product'\r\n\t\tAND posts.ID = meta.post_id\r\n\t\t{$addtoq}\r\n\t\tAND posts.post_status != 'trash' AND posts.post_status != 'revision'\r\n\t\tORDER BY meta.post_id");
        $calt = 0;
        $currsymbol = $eshopoptions['currency_symbol'];
        $x = 0;
        //add in post id( doh! )
        foreach ($myrowres as $row) {
            $grabit[$x] = maybe_unserialize(get_post_meta($row->post_id, '_eshop_product', true));
            //get_post_custom($row->post_id);
            $grabit[$x]['_eshop_stock'] = get_post_meta($row->post_id, '_eshop_stock', true);
            //get_post_custom($row->post_id);
            $grabit[$x]['id'] = $row->post_id;
            $grabit[$x]['_featured'] = '1';
            $grabit[$x]['_stock'] = '1';
            if (strtolower($grabit[$x]['featured']) == 'yes') {
                $grabit[$x]['_featured'] = '0';
            }
            if (strtolower($grabit[$x]['_eshop_stock']) == '1') {
                $grabit[$x]['_stock'] = '0';
            }
            $x++;
        }
        $array = $grabit;
        $grab = subval_sort($array, $sortby);
        //grabs some tax data
        if (!isset($eshopoptions['etax'])) {
            $eshopoptions['etax'] = array();
        }
        $etax = $eshopoptions['etax'];
        if (!isset($etax['bands']) || $etax['bands'] == '') {
            $etax['bands'] = '0';
        }
        ?>
	
		<form action="" method="post" class="eshop">
		<div class="eshopwidetable">
		<table class="hidealllabels widefat" summary="product listing">
		<caption><?php 
        _e('Product Quick reference table', 'eshop');
        ?>
</caption>
		<thead>
		<tr>
		<th id="sku"><?php 
        _e('Sku', 'eshop');
        ?>
</th>
		<th id="ids"><?php 
        _e('ID', 'eshop');
        ?>
</th>
		<th id="page"><?php 
        _e('Page', 'eshop');
        ?>
</th>
		<th id="desc"><?php 
        _e('Description', 'eshop');
        ?>
</th>
		<th id="down"><abbr title="<?php 
        _e('Downloads', 'eshop');
        ?>
"><?php 
        _e('DL', 'eshop');
        ?>
</abbr></th>
		<th id="ship"><abbr title="<?php 
        _e('Shipping Rate', 'eshop');
        ?>
"><?php 
        _e('S/R', 'eshop');
        ?>
</abbr></th>
		<th id="stkavail"><abbr title="<?php 
        _e('Stock Available', 'eshop');
        ?>
"><?php 
        _e('Stk avail.', 'eshop');
        ?>
</abbr></th>
		<th id="purc"><abbr title="<?php 
        _e('Number of Purchases', 'eshop');
        ?>
"><?php 
        _e('Purc.', 'eshop');
        ?>
</abbr></th>
		<th id="ftrd"><abbr title="<?php 
        _e('Marked as Featured', 'eshop');
        ?>
"><?php 
        _e('Feat.', 'eshop');
        ?>
</abbr></th>
		<th id="onsale" title="<?php 
        _e('Product on sale', 'eshop');
        ?>
"><?php 
        _e('Sale', 'eshop');
        ?>
</th>
		<th id="opt"><?php 
        _e('Option/Price', 'eshop');
        ?>
</th>
		<?php 
        if ($etax['bands'] > 0) {
            ?>
		<th id="tax"><?php 
            _e('Tax', 'eshop');
            ?>
</th>
		<?php 
        }
        ?>
		<th id="stk"><abbr title="<?php 
        _e('Stock Level', 'eshop');
        ?>
"><?php 
        _e('Stk', 'eshop');
        ?>
</abbr></th>
		<th id="associmg"><?php 
        _e('Thumbnail', 'eshop');
        ?>
</th>
		</tr>
		</thead>
		<tbody>
		<?php 
        $scc = 0;
        $start = $epage * $records - $records;
        $grab = array_slice($grab, $start, $records);
        foreach ($grab as $grabit) {
            $eshop_product = $grabit;
            if (isset($grabit['_eshop_stock']) && is_numeric($grabit['_eshop_stock'])) {
                $stkav = $grabit['_eshop_stock'];
            } else {
                $stkav = 0;
            }
            $pdownloads = 'no';
            if (isset($eshop_product['products']['1']['price']) && $eshop_product['products']['1']['price'] != '') {
                //reset array
                $purcharray = array();
                //get page title
                $ptitle = get_post($grabit['id']);
                $getid = $grabit['id'];
                //get download file title
                $pdown = '';
                //check if downloadable product
                for ($i = 1; $i <= $eshopoptions['options_num']; $i++) {
                    if ($eshop_product['products'][$i]['option'] != '') {
                        if (isset($eshop_product['products'][$i]['download']) && $eshop_product['products'][$i]['download'] != '') {
                            $dltable = $wpdb->prefix . 'eshop_downloads';
                            $fileid = $eshop_product['products'][$i]['download'];
                            $filetitle = $wpdb->get_var("SELECT title FROM {$dltable} WHERE id='{$fileid}'");
                            $pdown .= '<a href="admin.php?page=eshop-downloads.php&amp;edit=' . $fileid . '">' . $filetitle . '</a>';
                            $pdownloads = 'yes';
                        } else {
                            $pdown .= '<br />';
                        }
                    }
                }
                if ($ptitle->post_title == '') {
                    $posttitle = __('(no title)');
                } else {
                    $posttitle = $ptitle->post_title;
                }
                $calt++;
                $alt = $calt % 2 ? '' : ' class="alternate"';
                echo '<tr' . $alt . '>';
                echo '<td id="sku' . $calt . '" headers="sku">' . $eshop_product['sku'] . '</td>';
                echo '<td headers="ids sku' . $calt . '">' . $getid . '<input type="hidden" value="1" name="product[' . $getid . '][theid]" /></td>';
                echo '<td headers="page sku' . $calt . '"><a href="post.php?action=edit&amp;post=' . $getid . '" title="id: ' . $getid . '">' . $posttitle . '</a></td>';
                echo '<td headers="desc sku' . $calt . '">' . stripslashes(esc_attr($eshop_product['description'])) . '</td>';
                echo '<td headers="down sku' . $calt . '">' . $pdown . '</td>';
                echo '<td headers="ship sku' . $calt . '">' . $eshop_product['shiprate'] . '</td>';
                if ($stkav == '1') {
                    $stkchk = ' checked="checked"';
                } else {
                    $stkchk = '';
                }
                echo '<td headers="stkavail sku' . $calt . '"><label for="stkavail' . $calt . '">' . __('Stock Available', 'eshop') . '</label><input type="checkbox" value="1" name="product[' . $getid . '][stkavail]" id="stkavail' . $calt . '"' . $stkchk . ' /></td>';
                $purcharray = array();
                $dltable = $wpdb->prefix . "eshop_downloads";
                $stocktable = $wpdb->prefix . "eshop_stock";
                for ($i = 1; $i <= $eshopoptions['options_num']; $i++) {
                    if ($eshop_product['products'][$i]['option'] != '') {
                        if (isset($eshop_product['products'][$i]['download']) && $eshop_product['products'][$i]['download'] != '') {
                            $fileid = $eshop_product['products'][$i]['download'];
                            $purchases = $wpdb->get_var("SELECT purchases FROM {$dltable} WHERE id='{$fileid}'");
                            if ($purchases != '') {
                                $purcharray[] = $purchases;
                            } else {
                                $purcharray[] = '0';
                            }
                        } else {
                            $purchases = $wpdb->get_var("select purchases from {$stocktable} where post_id={$getid} && option_id={$i} limit 1");
                            if ($purchases != '') {
                                $purcharray[] = $purchases;
                            } else {
                                $purcharray[] = '0';
                            }
                        }
                    }
                    if ($pdownloads == 'no') {
                        break;
                    }
                }
                //Featured Product
                if ($eshop_product['featured'] == 'Yes') {
                    $fchk = ' checked="checked"';
                } else {
                    $fchk = '';
                }
                $feat = '<label for="featured' . $calt . '">' . __('Featured Product', 'eshop') . '</label><input type="checkbox" value="1" name="product[' . $getid . '][featured]" id="featured' . $calt . '"' . $fchk . ' />';
                echo '<td headers="purc sku' . $calt . '">' . implode("<br />", $purcharray) . '</td>';
                echo '<td headers="ftrd sku' . $calt . '">' . $feat . '</td>';
                //Sale Product
                if (isset($eshop_product['sale']) && $eshop_product['sale'] == 'yes') {
                    $salechk = ' checked="checked"';
                } else {
                    $salechk = '';
                }
                $onsale = '<label for="sale' . $calt . '">' . __('Product On Sale', 'eshop') . '</label><input type="checkbox" value="1" name="product[' . $getid . '][sale]" id="sale' . $calt . '"' . $salechk . ' />';
                echo '<td headers="onsale sku' . $calt . '">' . $onsale . '</td>';
                echo '<td headers="opt sku' . $calt . '" class="optline">';
                for ($i = 1; $i <= $numoptions; $i++) {
                    if ($eshop_product['products'][$i]['option'] != '') {
                        echo sprintf(__('%1$s @ %2$s%3$s', 'eshop'), stripslashes(esc_attr($eshop_product['products'][$i]['option'])), $currsymbol, number_format_i18n($eshop_product['products'][$i]['price'], __('2', 'eshop'))) . '<br />';
                    }
                }
                echo '</td>';
                if ($etax['bands'] > 0) {
                    echo '<td headers="tax sku' . $calt . '" class="optline">';
                    for ($i = 1; $i <= $numoptions; $i++) {
                        if (isset($eshop_product['products'][$i]['tax']) && $eshop_product['products'][$i]['tax'] != '') {
                            $tzone = sprintf(__('Band %1$d', 'eshop'), $eshop_product['products'][$i]['tax']);
                            $disptzone = apply_filters('eshop_rename_tax_zone', array());
                            if (isset($disptzone[$eshop_product['products'][$i]['tax']])) {
                                $tzone = $disptzone[$eshop_product['products'][$i]['tax']];
                            }
                            echo $tzone . '<br />';
                        } else {
                            echo '<br />';
                        }
                    }
                    echo '</td>';
                }
                //reset the string to stop multiple boxes!
                $pravailable = '';
                if ($eshopoptions['stock_control'] == 'yes') {
                    for ($i = 1; $i <= $numoptions; $i++) {
                        if ($eshop_product['products'][$i]['option'] != '') {
                            $available = $wpdb->get_var("select available from {$stocktable} where post_id={$getid} && option_id={$i} limit 1");
                            if ($available == '') {
                                $available = '0';
                            }
                            if (is_numeric($available) && $eshopoptions['stock_control'] == 'yes') {
                                $pravailable .= '<label for="stock' . $calt . '">' . __('Stock', 'eshop') . '</label><input type="text" value="' . $available . '" id="stock' . $scc . '" name="product[' . $getid . '][' . $i . '][stkqty]" size="4" /><br />' . "\n";
                                $scc++;
                            }
                        }
                    }
                } else {
                    $pravailable .= __('n/a', 'eshop') . '<br />';
                }
                echo '<td headers="stk sku' . $calt . '">' . $pravailable . '</td>';
                echo '<td headers="associmg sku' . $calt . '">';
                $w = get_option('thumbnail_size_w');
                $h = get_option('thumbnail_size_h');
                $imgsize = '50';
                $w = round($w * $imgsize / 100);
                $h = round($h * $imgsize / 100);
                if (has_post_thumbnail($getid)) {
                    echo '<a class="itemref" href="' . get_permalink($getid) . '" title="view page">' . get_the_post_thumbnail($getid, array($w, $h)) . '</a>' . "\n";
                } else {
                    $eimage = eshop_files_directory();
                    $eshopnoimage = apply_filters('eshop_no_image', $eimage['1'] . 'noimage.png');
                    echo '<a class="itemref" href="' . get_permalink($getid) . '" title="view page"><img src="' . $eshopnoimage . '" height="' . $h . '" width="' . $w . '" alt="" /></a>' . "\n";
                }
                echo '</td>';
                echo '</tr>' . "\n";
            }
        }
        ?>
		</tbody>
		</table>
		</div>
		<p><input type="submit" name="eshopqp" id="submitit" class="submit button-primary" value="<?php 
        _e('Update Products', 'eshop');
        ?>
" /></p>
		</form>
		<?php 
        //paginate
        echo '<div class="paginate tablenav-pages stuffbox">';
        if ($records != $max) {
            $eecho = $page_links;
        } else {
            --$records;
        }
        echo sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>', number_format_i18n(($epage - 1) * $records + 1), number_format_i18n(min($epage * $records, $max)), number_format_i18n($max));
        if (isset($eecho)) {
            $thispage = esc_url(add_query_arg('eshopall', 'yes', $_SERVER['REQUEST_URI']));
            echo "<ul class='page-numbers'>\n\t<li>" . join("</li>\n\t<li>", $eecho) . "</li>\n<li>" . '<a href="' . $thispage . '">' . __('View All', 'eshop') . '</a>' . "</li>\n</ul>\n";
        }
        echo '<br /></div>';
        //end
    } else {
        echo '<p>' . __('There are no products available.', 'eshop') . '</p>';
    }
    echo '</div>';
}
예제 #2
0
    function eshopShowform($first_name, $last_name, $company, $phone, $email, $address1, $address2, $city, $state, $altstate, $zip, $country, $reference, $comments, $ship_name, $ship_company, $ship_phone, $ship_address, $ship_city, $ship_postcode, $ship_state, $ship_altstate, $ship_country)
    {
        global $wpdb, $blog_id, $eshopoptions;
        $reqdvalues = array('shipping', 'first_name', 'last_name', 'email', 'phone', 'address', 'city', 'zip', 'pay');
        //setupshipping arrays
        if ($eshopoptions['shipping'] != '4') {
            if ($eshopoptions['shipping_zone'] == 'country') {
                $reqdvalues[] = 'country';
            } else {
                $reqdvalues[] = 'state';
            }
        } else {
            $creqd = '';
            $dtable = $wpdb->prefix . 'eshop_rates';
            $query = $wpdb->get_results("SELECT DISTINCT(area) from {$dtable} where rate_type='ship_weight'");
            foreach ($query as $k) {
                $reqdvalues[] = $k->area;
            }
        }
        $linkattr = apply_filters('eShopCheckoutLinksAttr', '');
        $reqdarray = apply_filters('eshopCheckoutReqd', $reqdvalues);
        $xtralinks = eshop_show_extra_links();
        $echo = '
	<div class="hr"></div>
	<div class="eshopcustdetails custdetails">
	<p><small class="privacy"><span class="reqd" title="Asterisk">*</span> ' . __('Denotes Required Field ', 'eshop') . '
	' . __($xtralinks, 'eshop') . '</small></p>
	<form action="' . esc_url($_SERVER['REQUEST_URI']) . '" method="post" class="eshop eshopform">';
        if ($eshopoptions['shipping'] == '4' && 'no' == $eshopoptions['downloads_only'] && !eshop_only_downloads()) {
            //only for ship by weight
            $echo .= '<fieldset class="eshop fld0"><legend id="shiplegend">' . __('Please Choose Shipping', 'eshop') . eshop_checkreqd($reqdarray, 'shipping') . '</legend>';
            $typearr = explode("\n", $eshopoptions['ship_types']);
            $cartweight = $_SESSION['eshop_totalweight' . $blog_id]['totalweight'];
            $eshopshiptable = '';
            $eshopletter = "A";
            $dtable = $wpdb->prefix . 'eshop_rates';
            $weightsymbol = $eshopoptions['weight_unit'];
            $currsymbol = $eshopoptions['currency_symbol'];
            $stype = '';
            if (isset($_POST['eshop_shiptype'])) {
                $stype = $_POST['eshop_shiptype'];
            }
            $first = apply_filters('eshop_default_shipping', '1');
            /* '1- text 2 - weight 3-weight symbol' */
            $echo .= '<p>' . sprintf(__('%1$s %2$s %3$s', 'eshop'), __('Total weight: ', 'eshop'), number_format_i18n($cartweight, __('2', 'eshop')), $weightsymbol) . '</p>';
            foreach ($typearr as $k => $type) {
                $k++;
                $query = $wpdb->get_results("SELECT * from {$dtable}  where weight<='{$cartweight}' &&  class='{$k}' && rate_type='ship_weight' order by weight DESC limit 1");
                if (count($query) == 0) {
                    continue;
                }
                if ($query['0']->maxweight != '' && $cartweight > $query['0']->maxweight) {
                    continue;
                }
                $eshopshiptableinner = '
			<table class="eshopshiprates eshop" summary="' . __('Shipping rates per mode', 'eshop') . '">
			<thead>
			<tr>';
                for ($z = 1; $z <= $eshopoptions['numb_shipzones']; $z++) {
                    $y = 'zone' . $z;
                    $echozone = sprintf(__('Zone %1$d', 'eshop'), $z);
                    $dispzone = apply_filters('eshop_rename_ship_zone', array());
                    if (isset($dispzone[$z])) {
                        $echozone = $dispzone[$z];
                    }
                    $eshopshiptableinner .= '<th id="' . $eshopletter . $y . '" class="' . $y . '">' . $echozone . '</th>';
                }
                $eshopshiptableinner .= '</tr>
			</thead>
			<tbody>';
                $x = 1;
                foreach ($query as $row) {
                    $alt = $x % 2 ? '' : ' class="alt"';
                    $eshopshiptableinner .= '
				<tr' . $alt . '>';
                    for ($z = 1; $z <= $eshopoptions['numb_shipzones']; $z++) {
                        $y = 'zone' . $z;
                        $eshopshiptableinner .= '<td headers="' . $eshopletter . $y . '" class="' . $y . '">' . sprintf(__('%1$s%2$s', 'eshop'), $currsymbol, $row->{$y}) . '</td>';
                    }
                    $eshopshiptableinner .= '</tr>';
                    $x++;
                }
                $eshopletter++;
                $eshopshiptableinner .= '</tbody></table>' . "\n";
                if ($row->area == 'country') {
                    $eshopshiptableheadtext = sprintf(__('%1$s <small>%2$s</small>', 'eshop'), stripslashes(esc_attr($type)), __('(Shipping Zones by Country)', 'eshop'));
                } else {
                    $eshopshiptableheadtext = sprintf(__('%1$s <small>%2$s</small>', 'eshop'), stripslashes(esc_attr($type)), __('(Shipping Zones by State/County/Province)', 'eshop'));
                }
                if (isset($row->maxweight) && $row->maxweight != '') {
                    $eshopshiptableheadtext .= ' ' . sprintf(__('Max. Weight %1$s %2$s', 'eshop'), $row->maxweight, $eshopoptions['weight_unit']);
                }
                if ($first == '1' && $stype == '') {
                    $stype = $k;
                    $first = 0;
                }
                $eshopshiptablehead = '<span><input class="rad" type="radio" name="eshop_shiptype" value="' . $k . '" id="eshop_shiptype' . $k . '"' . checked($stype, $k, false) . ' /> <label for="eshop_shiptype' . $k . '">' . $eshopshiptableheadtext . '</label></span>';
                $eshopshiptable .= $eshopshiptablehead . $eshopshiptableinner;
            }
            if ($eshopshiptable != '') {
                $echo .= $eshopshiptable;
            } else {
                $echo .= '<input type="hidden" name="eshop_shiptype" value="0" id="eshop_shiptype0" />';
            }
            $echo .= '</fieldset>';
        }
        $echo .= '<fieldset class="eshop fld1"><legend id="mainlegend">' . __('Please Enter Your Details', 'eshop') . '</legend>
	<fieldset class="eshop fld2">';
        if ('no' == $eshopoptions['downloads_only']) {
            $echo .= '<legend>' . __('Mailing Address', 'eshop') . '</legend>';
        } else {
            $echo .= '<legend>' . __('Contact Details', 'eshop') . '</legend>';
        }
        $echo .= '<span class="firstname"><label for="first_name">' . __('First Name', 'eshop') . eshop_checkreqd($reqdarray, 'first_name') . '</label>
	  <input class="med" type="text" name="first_name" value="' . $first_name . '" id="first_name" maxlength="40" size="40" /><br /></span>
	 <span class="lastname"><label for="last_name">' . __('Last Name', 'eshop') . eshop_checkreqd($reqdarray, 'last_name') . '</label>
	  <input class="med" type="text" name="last_name" value="' . $last_name . '" id="last_name" maxlength="40" size="40" /><br /></span>';
        if ('no' == $eshopoptions['downloads_only']) {
            $echo .= '<span class="company"><label for="company">' . __('Company', 'eshop') . eshop_checkreqd($reqdarray, 'company') . '</label>
	  <input class="med" type="text" name="company" value="' . $company . '" id="company" size="40" maxlength="255" /><br /></span>';
        }
        $echo .= '<span class="email"><label for="email">' . __('Email', 'eshop') . eshop_checkreqd($reqdarray, 'email') . '</label>
	  <input class="med" type="text" name="email" value="' . $email . '" id="email" maxlength="100" size="40" /><br /></span>';
        if ('no' == $eshopoptions['downloads_only']) {
            $echo .= '<span class="phone"><label for="phone">' . __('Phone', 'eshop') . eshop_checkreqd($reqdarray, 'phone') . '</label>
		  <input class="med" type="text" name="phone" value="' . $phone . '" id="phone" maxlength="30" size="30" /><br /></span>
		 <span class="address1"><label for="address1">' . __('Address', 'eshop') . eshop_checkreqd($reqdarray, 'address') . '</label>
		  <input class="med" type="text" name="address1" id="address1" value="' . $address1 . '" maxlength="40" size="40" /><br /></span>
		 <span class="address2"><label for="address2">' . __('Address (continued)', 'eshop') . '</label>
		  <input class="med" type="text" name="address2" id="address2" value="' . $address2 . '" maxlength="40" size="40" /><br /></span>
		 <span class="city"><label for="city">' . __('City or town', 'eshop') . eshop_checkreqd($reqdarray, 'city') . '</label>
		  <input class="med" type="text" name="city" value="' . $city . '" id="city" maxlength="40" size="40" /><br /></span>' . "\n";
            // state list from db
            $table = $wpdb->prefix . 'eshop_states';
            $getstate = $eshopoptions['shipping_state'];
            if ($eshopoptions['show_allstates'] != '1') {
                $stateList = $wpdb->get_results("SELECT id,code,stateName FROM {$table} WHERE list='{$getstate}' ORDER BY stateName", ARRAY_A);
            } else {
                $stateList = $wpdb->get_results("SELECT id,code,stateName,list FROM {$table} ORDER BY list,stateName", ARRAY_A);
            }
            if (sizeof($stateList) > 0) {
                $echo .= '<span class="state"><label for="state">' . __('State/County/Province', 'eshop') . eshop_checkreqd($reqdarray, 'state') . '</label>
			  <select class="med pointer" name="state" id="state">';
                $echo .= '<option value="">' . __('Please Select', 'eshop') . '</option>';
                $echo .= apply_filters('eshop_states_na', '<option value="">' . __('not applicable', 'eshop') . '</option>');
                foreach ($stateList as $code => $value) {
                    if (isset($value['list'])) {
                        $li = $value['list'];
                    } else {
                        $li = '1';
                    }
                    $eshopstatelist[$li][$value['id']] = array($value['code'], $value['stateName']);
                }
                $tablec = $wpdb->prefix . 'eshop_countries';
                foreach ($eshopstatelist as $egroup => $value) {
                    $eshopcname = $wpdb->get_var("SELECT country FROM {$tablec} where code='{$egroup}' limit 1");
                    $echo .= '<optgroup label="' . $eshopcname . '">' . "\n";
                    foreach ($value as $code => $stateName) {
                        //$stateName=esc_attr($stateName);
                        if (isset($state) && ($state == $stateName['0'] || $state == $code)) {
                            $echo .= '<option value="' . $code . '" selected="selected">' . $stateName['1'] . "</option>\n";
                        } else {
                            $echo .= '<option value="' . $code . '">' . $stateName['1'] . "</option>\n";
                        }
                    }
                    $echo .= "</optgroup>\n";
                }
                $echo .= "</select><br /></span>\n";
            } else {
                $echo .= '<input type="hidden" name="state" value="" />';
            }
            $echo .= '<span class="altstate"><label for="altstate">' . __('State/County/Province <small>if not listed above</small>', 'eshop') . '</label>
				  <input class="short" type="text" name="altstate" value="' . $altstate . '" id="altstate" size="20" /><br /></span>';
            $echo .= '
		 <span class="zip"><label for="zip">' . __('Zip/Post code', 'eshop') . eshop_checkreqd($reqdarray, 'zip') . '</label>
		  <input class="short" type="text" name="zip" value="' . $zip . '" id="zip" maxlength="20" size="20" /><br /></span>
		 <span class="country"><label for="country">' . __('Country', 'eshop') . eshop_checkreqd($reqdarray, 'country') . '</label>
		  <select class="med pointer" name="country" id="country">
		';
            // country list from db
            $tablec = $wpdb->prefix . 'eshop_countries';
            $List = $wpdb->get_results("SELECT code,country FROM {$tablec} GROUP BY list,country", ARRAY_A);
            foreach ($List as $key => $value) {
                $k = $value['code'];
                $v = $value['country'];
                $countryList[$k] = $v;
            }
            if (!isset($countryList)) {
                wp_die(__('Error, please contact site owner.', 'eshop'));
            }
            $echo .= '<option value="" selected="selected">' . __('Select your Country', 'eshop') . '</option>';
            foreach ($countryList as $code => $label) {
                $label = htmlspecialchars($label);
                if (isset($country) && $country == $code) {
                    $echo .= "<option value=\"{$code}\" selected=\"selected\">{$label}</option>\n";
                } else {
                    $echo .= "<option value=\"{$code}\">{$label}</option>";
                }
            }
            $echo .= "</select></span>";
        }
        $echo .= "</fieldset>";
        $echo = apply_filters('eshopaddtocheckout', $echo);
        if ('yes' != $eshopoptions['hide_addinfo']) {
            $echo .= '<fieldset class="eshop fld3">
		<legend>' . __('Additional information', 'eshop') . '</legend>
		 <span class="eshopreference"><label for="reference">' . __('Reference or <abbr title="Purchase Order number">PO</abbr>', 'eshop') . eshop_checkreqd($reqdarray, 'ref') . '</label>
		  <input type="text" class="med" name="reference" value="' . $reference . '" id="reference" size="30" maxlength="255" /><br /></span>
		 <label for="eshop-comments">' . __('Comments or special instructions', 'eshop') . eshop_checkreqd($reqdarray, 'comments') . '</label>
		  <textarea class="textbox" name="comments" id="eshop-comments" cols="60" rows="5">' . $comments . '</textarea>';
            $echo = apply_filters('eshopaddtoadditionalinformation', $echo);
            $echo .= "</fieldset>\n";
        }
        if ('no' == $eshopoptions['downloads_only']) {
            if ('yes' != $eshopoptions['hide_shipping']) {
                $echo .= '<fieldset class="eshop fld4">
			<legend>' . __('Shipping address (if different)', 'eshop') . '</legend>
			 <span class="ship_name"><label for="ship_name">' . __('Name', 'eshop') . '</label>
			  <input class="med" type="text" name="ship_name" id="ship_name" value="' . stripslashes(esc_attr($ship_name)) . '" maxlength="40" size="40" /><br /></span>
			 <span class="ship_company"><label for="ship_company">' . __('Company', 'eshop') . '</label>
			  <input class="med" type="text" name="ship_company" value="' . stripslashes(esc_attr($ship_company)) . '" id="ship_company" size="40" maxlength="255" /><br /></span>
			 <span class="ship_phone"><label for="ship_phone">' . __('Phone', 'eshop') . '</label>
			  <input class="med" type="text" name="ship_phone" value="' . $ship_phone . '" id="ship_phone" maxlength="30" size="30" /><br /></span>
			 <span class="ship_address"><label for="ship_address">' . __('Address', 'eshop') . '</label>
			  <input class="med" type="text" name="ship_address" id="ship_address" value="' . stripslashes(esc_attr($ship_address)) . '" maxlength="40" size="40" /><br /></span>
			 <span class="ship_city"><label for="ship_city">' . __('City or town', 'eshop') . '</label>
			  <input class="med" type="text" name="ship_city" id="ship_city" value="' . stripslashes(esc_attr($ship_city)) . '" maxlength="40" size="40" /><br /></span>' . "\n";
                if (isset($stateList) && sizeof($stateList) > 0) {
                    $echo .= '<span class="ship_state"><label for="shipstate">' . __('State/County/Province', 'eshop') . '</label>
				  <select class="med pointer" name="ship_state" id="shipstate">';
                    //state list from db, as above
                    $echo .= '<option value="" selected="selected">' . __('Please Select', 'eshop') . '</option>';
                    $echo .= apply_filters('eshop_states_na', '<option value="">' . __('not applicable', 'eshop') . '</option>');
                    foreach ($eshopstatelist as $egroup => $value) {
                        $eshopcname = $wpdb->get_var("SELECT country FROM {$tablec} where code='{$egroup}' limit 1");
                        $echo .= '<optgroup label="' . $eshopcname . '">' . "\n";
                        foreach ($value as $code => $stateName) {
                            //$stateName=htmlspecialchars($stateName);
                            if (isset($ship_state) && ($ship_state == $code || $ship_state == $stateName['0'])) {
                                $echo .= '<option value="' . $code . '" selected="selected">' . $stateName['1'] . "</option>\n";
                            } else {
                                $echo .= '<option value="' . $code . '">' . $stateName['1'] . "</option>\n";
                            }
                        }
                        $echo .= "</optgroup>\n";
                    }
                    $echo .= '</select><br /></span>';
                } else {
                    $echo .= '<input type="hidden" name="ship_state" value="" />';
                }
                $echo .= '<span class="ship_altstate"><label for="ship_altstate">' . __('State/County/Province <small>if not listed above</small>', 'eshop') . '</label>
					 <input class="short" type="text" name="ship_altstate" value="' . stripslashes(esc_attr($ship_altstate)) . '" id="ship_altstate" size="20" /><br /></span>';
                $echo .= '<span class="shippostcode"><label for="ship_postcode">' . __('Zip/Post Code', 'eshop') . '</label>
			  <input class="short" type="text" name="ship_postcode" id="ship_postcode" value="' . $ship_postcode . '" maxlength="20" size="20" />
			  <br /></span>
			<span class="shipcountry"><label for="shipcountry">' . __('Country', 'eshop') . '</label>
			  <select class="med pointer" name="ship_country" id="shipcountry">
			';
                $echo .= '<option value="" selected="selected">' . __('Select your Country', 'eshop') . '</option>';
                foreach ($countryList as $code => $label) {
                    $label = htmlspecialchars($label);
                    if (isset($ship_country) && $ship_country == $code) {
                        $echo .= "<option value=\"{$code}\" selected=\"selected\">{$label}</option>\n";
                    } else {
                        $echo .= "<option value=\"{$code}\">{$label}</option>";
                    }
                }
                $echo .= "</select></span>";
                $echo .= '</fieldset>';
            }
        }
        $final_price = number_format($_SESSION['final_price' . $blog_id], 2, '.', '');
        $discounttotal = 0;
        if (eshop_discount_codes_check()) {
            $eshop_discount = '';
            if (isset($_POST['eshop_discount'])) {
                $eshop_discount = esc_attr($_POST['eshop_discount']);
            }
            $echo .= '<fieldset class="eshop fld5"><legend><label for="eshop_discount">' . __('Discount Code', 'eshop') . '</label></legend>
	  	<input class="med" type="text" name="eshop_discount" value="' . $eshop_discount . '" id="eshop_discount" size="40" /></fieldset>' . "\n";
        }
        if (is_array($eshopoptions['method'])) {
            $i = 1;
            $eshopfiles = eshop_files_directory();
            $echo .= '<fieldset class="eshop fld6 eshoppayvia"><legend>' . __('Pay Via', 'eshop') . eshop_checkreqd($reqdarray, 'pay') . '</legend>' . "\n";
            $echo = apply_filters('eshopaddtocheckoutpayvia', $echo);
            $echo .= "<ul>\n";
            $eshop_paymentx = '';
            if (isset($_POST['eshop_payment'])) {
                $eshop_paymentx = $_POST['eshop_payment'];
            }
            if (sizeof((array) $eshopoptions['method']) != 1) {
                foreach ($eshopoptions['method'] as $k => $eshoppayment) {
                    $replace = array(".");
                    $eshoppayment = str_replace($replace, "", $eshoppayment);
                    $eshoppayment_text = $eshoppayment;
                    if ($eshoppayment_text == 'cash') {
                        $eshopcash = $eshopoptions['cash'];
                        if ($eshopcash['rename'] != '') {
                            $eshoppayment_text = $eshopcash['rename'];
                        }
                    }
                    if ($eshoppayment_text == 'bank') {
                        $eshopbank = $eshopoptions['bank'];
                        if ($eshopbank['rename'] != '') {
                            $eshoppayment_text = $eshopbank['rename'];
                        }
                    }
                    $eshopmi = apply_filters('eshop_merchant_img_' . $eshoppayment, array('path' => $eshopfiles['0'] . $eshoppayment . '.png', 'url' => $eshopfiles['1'] . $eshoppayment . '.png'));
                    $eshopmerchantimgpath = $eshopmi['path'];
                    $eshopmerchantimgurl = $eshopmi['url'];
                    $dims = array('3' => '');
                    if (file_exists($eshopmerchantimgpath)) {
                        $dims = getimagesize($eshopmerchantimgpath);
                    }
                    $echo .= '<li><input class="rad" type="radio" name="eshop_payment" value="' . $eshoppayment . '" id="eshop_payment' . $i . '"' . checked($eshop_paymentx, $eshoppayment, false) . ' /><label for="eshop_payment' . $i . '"><img src="' . $eshopmerchantimgurl . '" ' . $dims[3] . ' alt="' . __('Pay via', 'eshop') . ' ' . $eshoppayment_text . '" title="' . __('Pay via', 'eshop') . ' ' . $eshoppayment_text . '" /></label></li>' . "\n";
                    $i++;
                }
            } else {
                foreach ($eshopoptions['method'] as $k => $eshoppayment) {
                    $replace = array(".");
                    $eshoppayment = str_replace($replace, "", $eshoppayment);
                    $eshoppayment_text = $eshoppayment;
                    if ($eshoppayment_text == 'cash') {
                        $eshopcash = $eshopoptions['cash'];
                        if ($eshopcash['rename'] != '') {
                            $eshoppayment_text = $eshopcash['rename'];
                        }
                    }
                    if ($eshoppayment_text == 'bank') {
                        $eshopbank = $eshopoptions['bank'];
                        if ($eshopbank['rename'] != '') {
                            $eshoppayment_text = $eshopbank['rename'];
                        }
                    }
                    $eshopmi = apply_filters('eshop_merchant_img_' . $eshoppayment, array('path' => $eshopfiles['0'] . $eshoppayment . '.png', 'url' => $eshopfiles['1'] . $eshoppayment . '.png'));
                    $eshopmerchantimgpath = $eshopmi['path'];
                    $eshopmerchantimgurl = $eshopmi['url'];
                    $dims = '';
                    if (file_exists($eshopmerchantimgpath)) {
                        $dims = getimagesize($eshopmerchantimgpath);
                    }
                    $echo .= '<li><img src="' . $eshopmerchantimgurl . '" ' . $dims[3] . ' alt="' . __('Pay via', 'eshop') . ' ' . $eshoppayment_text . '" title="' . __('Pay via', 'eshop') . ' ' . $eshoppayment_text . '" /><input type="hidden" name="eshop_payment" value="' . $eshoppayment . '" id="eshop_payment' . $i . '" /></li>' . "\n";
                    $i++;
                }
            }
            $echo .= "</ul>\n";
            $echo .= eshopCartFields();
            $echo .= "</fieldset>\n";
        }
        if ('yes' == $eshopoptions['tandc_use']) {
            if ($eshopoptions['tandc_id'] != '') {
                $eshoptc = '<a href="' . get_permalink($eshopoptions['tandc_id']) . '"' . $linkattr . '>' . $eshopoptions['tandc'] . '</a>';
            } else {
                $eshoptc = $eshopoptions['tandc'];
            }
            $echo .= '<p class="eshop_tandc"><input type="checkbox" name="eshop_tandc" id="eshop_tandc" value="1" /><label for="eshop_tandc">' . $eshoptc . '<span class="reqd">*</span></label></p>';
        }
        if (isset($eshopoptions['users']) && $eshopoptions['users'] == 'yes' && !is_user_logged_in()) {
            if (isset($eshopoptions['users_text']) && $eshopoptions['users_text'] != '') {
                $edisplay = $eshopoptions['users_text'];
            } else {
                $edisplay = __('Sign me up to the site so I can view my orders.', 'eshop');
            }
            $echo .= '<p class="eshop_users"><input type="checkbox" name="eshop_users" id="eshop_users" value="1" /><label for="eshop_users">' . $edisplay . eshop_checkreqd($reqdarray, 'signup') . '</label></p>';
        }
        if ('no' == $eshopoptions['downloads_only']) {
            $echo .= '<label for="submitit"><small id="eshopshowshipcost">' . __('<strong>Note:</strong> Submit to show shipping charges.', 'eshop') . '</small></label><br />';
        }
        $echo .= '<input type="hidden" name="amount" value="' . $final_price . '" />';
        $echo .= '<span class="buttonwrap"><input type="submit" class="button" id="submitit" name="submit" value="' . __('Proceed to Confirmation &raquo;', 'eshop') . '" /></span>
	</fieldset>
	</form>
	</div>
	';
        if (get_bloginfo('version') < '2.5.1') {
            remove_filter('the_content', 'wpautop');
        }
        return $echo;
    }
예제 #3
0
function eshop_base_manager()
{
    global $wpdb, $eshopoptions;
    include 'eshop-base-functions.php';
    if (!isset($_GET['change'])) {
        ?>
	<div class="wrap">
	<div id="eshopicon" class="icon32"></div><h2><?php 
        _e('eShop Base Products', 'eshop');
        ?>
</h2>
	<?php 
        eshop_admin_mode();
        ?>
	<ul>
	<?php 
        $dlpage = '?page=' . $_GET['page'] . '&amp;eshopbasedl=yes';
        ?>
	<li><a href="<?php 
        echo $dlpage;
        ?>
&amp;d=1"><?php 
        _e('Download the xml file', 'eshop');
        ?>
</a></li>
	<li><a href="<?php 
        echo $dlpage;
        ?>
&amp;d=1&amp;os=mac"><?php 
        _e('Mac - Download the xml file', 'eshop');
        ?>
</a></li>
	<li><a href="<?php 
        echo $dlpage;
        ?>
"><?php 
        _e('View xml file', 'eshop');
        ?>
</a></li>
	<li><?php 
        echo sprintf(__('Direct link to file for Google Base: <a href="%1$s">%1$s</a>', 'eshop'), trim(site_url(), '/') . '/?eshopbasefeed');
        ?>
</li>
	</ul>
	<?php 
        //sort by switch statement
        $csa = $csb = $csc = $csd = $cse = $csf = '';
        if (isset($_GET['by'])) {
            switch ($_GET['by']) {
                case 'sa':
                    //date descending
                    $sortby = 'sku';
                    $csa = ' class="current"';
                    break;
                case 'sb':
                    //description alphabetically
                    $sortby = 'description';
                    $csb = ' class="current"';
                    break;
                    /*
                    	case'sd'://stock availability 
                    		$sortby='_eshop_stock';
                    		$csd=' class="current"';
                    		break;
                    */
                /*
                	case'sd'://stock availability 
                		$sortby='_eshop_stock';
                		$csd=' class="current"';
                		break;
                */
                case 'sf':
                    //date ascending
                //date ascending
                default:
                    $sortby = 'id';
                    $csf = ' class="current"';
            }
        } else {
            $csf = ' class="current"';
            $sortby = 'id';
        }
        $numoptions = $eshopoptions['options_num'];
        $metatable = $wpdb->prefix . 'postmeta';
        $poststable = $wpdb->prefix . 'posts';
        $stocktable = $wpdb->prefix . "eshop_stock";
        $range = 10;
        $max = $wpdb->get_var("SELECT COUNT(meta.post_id) FROM {$metatable} as meta, \n\t{$poststable} as posts where meta.meta_key='_eshop_product' \n\tAND posts.ID = meta.post_id\t\n\tAND posts.post_status != 'trash' AND posts.post_status != 'revision'");
        if ($eshopoptions['records'] != '' && is_numeric($eshopoptions['records'])) {
            $records = $eshopoptions['records'];
        } else {
            $records = '10';
        }
        if (isset($_GET['_p']) && is_numeric($_GET['_p'])) {
            $epage = $_GET['_p'];
        } else {
            $epage = '1';
        }
        if (!isset($_GET['eshopall'])) {
            $page_links = paginate_links(array('base' => add_query_arg('_p', '%#%'), 'format' => '', 'total' => ceil($max / $records), 'current' => $epage, 'type' => 'array'));
            $offset = $epage * $records - $records;
        } else {
            $page_links = paginate_links(array('base' => add_query_arg('_p', '%#%'), 'format' => '', 'total' => ceil($max / $records), 'current' => $epage, 'type' => 'array', 'show_all' => true));
            $offset = '0';
            $records = $max;
        }
        if ($max > 0) {
            $apge = get_admin_url() . 'admin.php?page=eshop-base.php';
            echo '<ul id="eshopsubmenu" class="stuffbox">';
            echo '<li><span>' . __('Sort Orders by &raquo;', 'eshop') . '</span></li>';
            echo '<li><a href="' . $apge . '&amp;by=sf"' . $csf . '>' . __('ID Number', 'eshop') . '</a></li>';
            echo '<li><a href="' . $apge . '&amp;by=sa"' . $csa . '>' . __('Sku', 'eshop') . '</a></li>';
            echo '<li><a href="' . $apge . '&amp;by=sb"' . $csb . '>' . __('Product', 'eshop') . '</a></li>';
            // echo '<li><a href="'.$apge.'&amp;by=sd"'.$csd.'>'.__('Stock','eshop').'</a></li>';
            echo '</ul>';
            $myrowres = $wpdb->get_results("\n\t\tSELECT DISTINCT meta.post_id\n\t\tFROM {$metatable} as meta, {$poststable} as posts\n\t\tWHERE meta.meta_key = '_eshop_product'\n\t\tAND posts.ID = meta.post_id\n\t\tAND posts.post_status != 'trash' AND posts.post_status != 'revision'\n\t\tORDER BY meta.post_id");
            $calt = 0;
            $currsymbol = $eshopoptions['currency_symbol'];
            $x = 0;
            //add in post id( doh! )
            foreach ($myrowres as $row) {
                $grabit[$x] = maybe_unserialize(get_post_meta($row->post_id, '_eshop_product', true));
                //get_post_custom($row->post_id);
                $grabit[$x]['_eshop_stock'] = get_post_meta($row->post_id, '_eshop_stock', true);
                //get_post_custom($row->post_id);
                $grabit[$x]['id'] = $row->post_id;
                $grabit[$x]['_featured'] = '1';
                $grabit[$x]['_stock'] = '1';
                if (strtolower($grabit[$x]['featured']) == 'yes') {
                    $grabit[$x]['_featured'] = '0';
                }
                if (strtolower($grabit[$x]['_eshop_stock']) == '1') {
                    $grabit[$x]['_stock'] = '0';
                }
                $x++;
            }
            $array = $grabit;
            $grab = eshop_subval_sort($array, $sortby);
            ?>
	
		<table class="widefat">
		<caption><?php 
            _e('Product Quick reference table', 'eshop');
            ?>
</caption>
		<thead>
		<tr>
		<th id="sku"><?php 
            _e('Sku', 'eshop');
            ?>
</th>
		<th id="page"><?php 
            _e('Page', 'eshop');
            ?>
</th>
		<th id="desc"><?php 
            _e('Description', 'eshop');
            ?>
</th>
		<th id="down"><?php 
            _e('Download', 'eshop');
            ?>
</th>
		<th id="stkavail"><abbr title="<?php 
            _e('Stock Available', 'eshop');
            ?>
"><?php 
            _e('Stk avail.', 'eshop');
            ?>
</abbr></th>
		<th id="stk"><?php 
            _e('Stock', 'eshop');
            ?>
</th>
		<th id="opt"><?php 
            _e('Option/Price', 'eshop');
            ?>
</th>
		<th id="imga"><?php 
            _e('Image', 'eshop');
            ?>
</th>

		</tr>
		</thead>
		<tbody>
		<?php 
            $start = $epage * $records - $records;
            if (isset($_GET['eshopall'])) {
                $start = 0;
            }
            $grab = array_slice($grab, $start, $records);
            foreach ($grab as $foo => $grabit) {
                $eshop_product = $grabit;
                if (isset($grabit['_eshop_stock'])) {
                    $stkav = $grabit['_eshop_stock'];
                } else {
                    $stkav = 0;
                }
                if (isset($eshop_product['products']['1']['price']) && $eshop_product['products']['1']['price'] != '') {
                    //get page title
                    $ptitle = get_post($grabit['id']);
                    $pdown = '';
                    //check if downloadable product
                    for ($i = 1; $i <= $eshopoptions['options_num']; $i++) {
                        if ($eshop_product['products'][$i]['option'] != '') {
                            if (isset($eshop_product['products'][$i]['download']) && $eshop_product['products'][$i]['download'] != '') {
                                $dltable = $wpdb->prefix . 'eshop_downloads';
                                $fileid = $eshop_product['products'][$i]['download'];
                                $filetitle = $wpdb->get_var("SELECT title FROM {$dltable} WHERE id='{$fileid}'");
                                $pdown .= '<a href="admin.php?page=eshop-downloads.php&amp;edit=' . $fileid . '">' . $filetitle . '</a>';
                                $pdownloads = 'yes';
                            } else {
                                $pdown .= '<br />';
                            }
                        }
                    }
                    if ($ptitle->post_title == '') {
                        $posttitle = __('(no title)', 'eshop');
                    } else {
                        $posttitle = $ptitle->post_title;
                    }
                    $calt++;
                    $alt = $calt % 2 ? '' : ' class="alternate"';
                    echo '<tr' . $alt . '>';
                    echo '<td id="sku' . $calt . '" headers="sku"><a href="admin.php?page=eshop-base.php&amp;change=' . $grabit['id'] . '" title="' . __('Change details', 'eshop') . '">' . $eshop_product['sku'] . '</a></td>';
                    echo '<td headers="page sku' . $calt . '"><a href="post.php?action=edit&amp;post=' . $grabit['id'] . '">' . $posttitle . '</a></td>';
                    echo '<td headers="desc sku' . $calt . '">' . stripslashes(esc_attr($eshop_product['description'])) . '</td>';
                    echo '<td headers="down sku' . $calt . '">' . $pdown . '</td>';
                    if ($stkav == '1') {
                        $stkchk = __('Yes', 'eshop');
                    } else {
                        $stkchk = __('No', 'eshop');
                    }
                    echo '<td headers="stkavail sku' . $calt . '">' . $stkchk . '</td>';
                    $pid = $grabit['id'];
                    if ($eshopoptions['stock_control'] == 'yes') {
                        $pravailable = '';
                        $getid = $grabit['id'];
                        for ($i = 1; $i <= $numoptions; $i++) {
                            if ($eshop_product['products'][$i]['option'] != '') {
                                $available = $wpdb->get_var("select available from {$stocktable} where post_id={$getid} && option_id={$i} limit 1");
                                if ($available == '' || $available < 0) {
                                    $available = '0';
                                }
                                if (is_numeric($available) && $eshopoptions['stock_control'] == 'yes') {
                                    $pravailable .= $available . '<br />' . "\n";
                                }
                            }
                        }
                    } else {
                        $pravailable = __('n/a', 'eshop') . '<br />';
                    }
                    echo '<td headers="stk sku' . $calt . '">' . $pravailable . '</td>';
                    echo '<td headers="opt sku' . $calt . '">';
                    for ($i = 1; $i <= $numoptions; $i++) {
                        if ($eshop_product['products'][$i]['option'] != '') {
                            echo sprintf(__('%1$s @ %2$s%3$s', 'eshop'), stripslashes(esc_attr($eshop_product['products'][$i]['option'])), $currsymbol, number_format_i18n($eshop_product['products'][$i]['price'], __('2', 'eshop'))) . '<br />';
                        }
                    }
                    echo '</td>';
                    echo '<td>';
                    $getid = $grabit['id'];
                    $w = get_option('thumbnail_size_w');
                    $h = get_option('thumbnail_size_h');
                    $imgsize = '50';
                    $w = round($w * $imgsize / 100);
                    $h = round($h * $imgsize / 100);
                    if (has_post_thumbnail($getid)) {
                        echo '<a class="itemref" href="' . get_permalink($getid) . '">' . get_the_post_thumbnail($getid, array($w, $h)) . '</a>' . "\n";
                    } else {
                        $eimage = eshop_files_directory();
                        $eshopnoimage = apply_filters('eshop_no_image', $eimage['1'] . 'noimage.png');
                        echo '<a class="itemref" href="' . get_permalink($getid) . '"><img src="' . $eshopnoimage . '" height="' . $h . '" width="' . $w . '" alt="" /></a>' . "\n";
                    }
                    echo '</td>';
                    echo '</tr>';
                }
            }
            ?>
		</tbody>
		</table>
		<?php 
            //paginate
            echo '<div class="paginate tablenav-pages stuffbox">';
            if ($records != $max) {
                $eecho = $page_links;
            }
            if (isset($_GET['eshopall'])) {
                $eshopdisp = number_format_i18n(1);
            } else {
                $eshopdisp = number_format_i18n(($epage - 1) * $records + 1);
            }
            echo sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s', 'eshop') . '</span>', $eshopdisp, number_format_i18n(min($epage * $records, $max)), number_format_i18n($max));
            if (isset($eecho)) {
                $thispage = esc_url(add_query_arg('eshopall', 'yes', $_SERVER['REQUEST_URI']));
                echo "<ul class='page-numbers'>\n\t<li>" . join("</li>\n\t<li>", $eecho) . "</li>\n<li>" . '<a href="' . $thispage . '">' . __('View All', 'eshop') . '</a>' . "</li>\n</ul>\n";
            }
            echo '<br /></div>';
            //end
        } else {
            echo '<p>' . __('There are no products available.', 'eshop') . '</p>';
        }
        echo '</div>';
    } else {
        //////////change one.
        //form checks:
        $basetable = $wpdb->prefix . "eshop_base_products";
        $change = $_GET['change'];
        if (is_numeric($change)) {
            if (isset($_POST['submit'])) {
                include 'cart-functions.php';
                if (get_magic_quotes_gpc() == 0) {
                    $_POST = stripslashes_array($_POST);
                }
                $_POST = sanitise_array($_POST);
                $err = '';
                if (isset($_POST['baseimg'])) {
                    $baseimg = esc_sql($_POST['baseimg']);
                } else {
                    $baseimg = '';
                }
                $basebrand = esc_sql($_POST['basebrand']);
                $baseean = esc_sql($_POST['baseean']);
                $baseisbn = esc_sql($_POST['baseisbn']);
                $basempn = esc_sql($_POST['basempn']);
                $baseptype = esc_sql($_POST['baseptype']);
                $baseqty = esc_sql($_POST['baseqty']);
                $basecondition = esc_sql($_POST['basecondition']);
                $baseexpiration_year = $_POST['baseexpiration_year'];
                $baseexpiration_month = $_POST['baseexpiration_month'];
                $baseexpiration_day = $_POST['baseexpiration_day'];
                if (!is_numeric($baseqty)) {
                    $baseqty = '25';
                    $err .= '<li>' . __('Quantity was not numeric, a default of 25 has been applied.', 'eshop') . '</li>';
                }
                $baseexpiration = esc_sql($baseexpiration_year . '-' . $baseexpiration_month . '-' . $baseexpiration_day);
                //enter in db - delete old record first,
                //then it will always be an insert and easier than checking for update.
                $wpdb->query("DELETE FROM {$basetable} WHERE post_id = {$change} limit 1");
                $wpdb->query("INSERT INTO {$basetable} (\n\t\t\tpost_id,img,brand,ptype,thecondition,expiry,ean,isbn,mpn,qty\n\t\t\t)VALUES(\n\t\t\t'{$change}','{$baseimg}','{$basebrand}','{$baseptype}','{$basecondition}','{$baseexpiration}',\n\t\t\t'{$baseean}','{$baseisbn}','{$basempn}','{$baseqty}'\n\t\t\t)");
                if ($err != '') {
                    echo '<div id="message" class="error fade"><p>' . __('<strong>Error</strong> the following were not valid:', 'eshop') . '</p><ul>' . $err . '</ul></div>' . "\n";
                } else {
                    echo '<div id="message" class="updated fade"><p>' . __('eshop Base details for this product have been updated.', 'eshop') . '</p></div>' . "\n";
                }
            }
            $basedata = $wpdb->get_row("SELECT * FROM {$basetable} WHERE post_id = {$change}");
            if ($basedata == '') {
                $basedata->post_id = $basedata->img = $basedata->brand = $basedata->ptype = $basedata->thecondition = $basedata->expiry = $basedata->ean = $basedata->isbn = $basedata->mpn = $basedata->qty = '';
            }
            ?>
		<div class="wrap">
		<div id="eshopicon" class="icon32"></div><h2><?php 
            _e('eShop Base Product', 'eshop');
            ?>
</h2>
		<?php 
            eshop_admin_mode();
            ?>

		<?php 
            //sort by switch statement
            $sortby = 'id';
            $csf = ' class="current"';
            $numoptions = $eshopoptions['options_num'];
            $metatable = $wpdb->prefix . 'postmeta';
            $calt = 0;
            $currsymbol = $eshopoptions['currency_symbol'];
            $x = 0;
            //add in post id( doh! )
            $grabit[$x] = get_post_custom($change);
            $grabit[$x]['id'] = array($change);
            $x++;
            /*
             * remove the bottom array to try and flatten
             * could be rather slow, but easier than trying to create
             * a different method, at least for now!
             */
            foreach ($grabit as $foo => $k) {
                foreach ($k as $bar => $v) {
                    if ($bar == '_eshop_product') {
                        $y = unserialize($v[0]);
                        foreach ($y as $nowt => $val) {
                            $grab[$foo][$nowt] = $val;
                        }
                    }
                    foreach ($v as $nowt => $val) {
                        $grab[$foo][$bar] = $val;
                    }
                }
            }
            ?>
	
		<table class="widefat">
		<caption><?php 
            _e('Product Quick reference table', 'eshop');
            ?>
</caption>
		<thead>
		<tr>
		<th id="sku"><?php 
            _e('Sku', 'eshop');
            ?>
</th>
		<th id="page"><?php 
            _e('Page', 'eshop');
            ?>
</th>
		<th id="desc"><?php 
            _e('Description', 'eshop');
            ?>
</th>
		<th id="down"><?php 
            _e('Download', 'eshop');
            ?>
</th>
		<th id="stk"><?php 
            _e('Stock', 'eshop');
            ?>
</th>
		<th id="opt"><?php 
            _e('Option/Price', 'eshop');
            ?>
</th>
		<th id="imga"><?php 
            _e('Image', 'eshop');
            ?>
</th>
		</tr>
		</thead>
		<tbody>
		<?php 
            foreach ($grab as $foo => $grabit) {
                $pdownloads = 'no';
                if ($grabit['products']['1']['price'] != '') {
                    if (isset($grabit['_eshop_stock'])) {
                        $stkav = $grabit['_eshop_stock'];
                    } else {
                        $stkav = 0;
                    }
                    //get page title
                    $ptitle = get_post($grabit['id']);
                    $pdown = '';
                    //check if downloadable product
                    for ($i = 1; $i <= $eshopoptions['options_num']; $i++) {
                        if (isset($grabit['products'][$i]['option']) && $grabit['products'][$i]['option'] != '') {
                            if (isset($grabit['products'][$i]['download']) && $grabit['products'][$i]['download'] != '') {
                                $dltable = $wpdb->prefix . 'eshop_downloads';
                                $fileid = $grabit['products'][$i]['download'];
                                $filetitle = $wpdb->get_var("SELECT title FROM {$dltable} WHERE id='{$fileid}'");
                                $pdown .= '<a href="admin.php?page=eshop-downloads.php&amp;edit=' . $fileid . '">' . $filetitle . '</a>';
                                $pdownloads = 'yes';
                            } else {
                                $pdown .= '<br />';
                            }
                        }
                    }
                    $calt++;
                    $alt = $calt % 2 ? '' : ' class="alternate"';
                    echo '<tr' . $alt . '>';
                    echo '<td id="sku' . $calt . '" headers="sku">' . $grabit['sku'] . '</td>';
                    echo '<td headers="page sku' . $calt . '"><a href="page.php?action=edit&amp;post=' . $grabit['id'] . '">' . $ptitle->post_title . '</a></td>';
                    echo '<td headers="desc sku' . $calt . '">' . stripslashes(esc_attr($grabit['description'])) . '</td>';
                    echo '<td headers="down sku' . $calt . '">' . $pdown . '</td>';
                    $pid = $grabit['id'];
                    $stocktable = $wpdb->prefix . "eshop_stock";
                    $pravailable = '';
                    if ($eshopoptions['stock_control'] == 'yes') {
                        for ($i = 1; $i <= $numoptions; $i++) {
                            if ($grabit['products'][$i]['option'] != '') {
                                $available = $wpdb->get_var("select available from {$stocktable} where post_id={$pid} && option_id={$i} limit 1");
                                if ($available == '' || $available < 0) {
                                    $available = '0';
                                }
                                if (is_numeric($available) && $eshopoptions['stock_control'] == 'yes') {
                                    $pravailable .= $available . '<br />' . "\n";
                                }
                            }
                        }
                    } else {
                        $pravailable .= __('n/a', 'eshop') . '<br />';
                    }
                    echo '<td headers="stk sku' . $calt . '">' . $pravailable . '</td>';
                    echo '<td headers="opt sku' . $calt . '">';
                    for ($i = 1; $i <= $numoptions; $i++) {
                        if (isset($grabit['products'][$i]['option']) && $grabit['products'][$i]['option'] != '') {
                            echo sprintf(__('%1$s @ %2$s%3$s', 'eshop'), stripslashes(esc_attr($grabit['products'][$i]['option'])), $currsymbol, number_format_i18n($grabit['products'][$i]['price'], __('2', 'eshop'))) . '<br />';
                        }
                    }
                    echo '</td>';
                    echo '<td>';
                    $w = get_option('thumbnail_size_w');
                    $h = get_option('thumbnail_size_h');
                    $imgsize = '50';
                    if ($imgsize != '') {
                        $w = round($w * $imgsize / 100);
                        $h = round($h * $imgsize / 100);
                    }
                    if (has_post_thumbnail($change)) {
                        echo '<a class="itemref" href="' . get_permalink($change) . '">' . get_the_post_thumbnail($change, array($w, $h)) . '</a>' . "\n";
                    } else {
                        $eimage = eshop_files_directory();
                        $eshopnoimage = apply_filters('eshop_no_image', $eimage['1'] . 'noimage.png');
                        echo '<a class="itemref" href="' . get_permalink($change) . '"><img src="' . $eshopnoimage . '" height="' . $h . '" width="' . $w . '" alt="" /></a>' . "\n";
                    }
                    echo '</td>' . "\n";
                    echo '</tr>' . "\n";
                }
                ?>
		</tbody>
		</table>
		<?php 
            }
            echo '<h3>' . __('Additional settings', 'eshop') . '</h3>' . "\n";
            $id = $grabit['id'];
            ?>
		<form method="post" action="" id="eshop-gbase-alt">
		<fieldset id="baseothers"><legend><?php 
            _e('Others', 'eshop');
            ?>
</legend>
		<?php 
            if (has_post_thumbnail($id)) {
                $grabimg = get_post_thumbnail_id($id);
                $src = wp_get_attachment_image_src($grabimg);
                ?>
		<input type="hidden" name="baseimg" value="<?php 
                echo $src['0'];
                ?>
" />
		<?php 
            }
            ?>
		<label for="basebrand"><?php 
            _e('Brand <small>The brand name of the product</small>', 'eshop');
            ?>
</label>
		<input type="text" name="basebrand" id="basebrand" value="<?php 
            echo esc_html($basedata->brand);
            ?>
" />
		<label for="baseean"><?php 
            _e('EAN <small>European Article Number is a 13 digit number often below the bar code of the item.</small>', 'eshop');
            ?>
</label>
		<input type="text" name="baseean" id="baseean" value="<?php 
            echo esc_html($basedata->ean);
            ?>
" />
		<label for="baseisbn"><?php 
            _e('ISBN <small>The unique 10- or 13-digit number assigned to every printed book.</small>', 'eshop');
            ?>
</label>
		<input type="text" name="baseisbn" id="baseisbn" value="<?php 
            echo esc_html($basedata->isbn);
            ?>
" />
		<label for="basempn"><?php 
            _e('MPN <small>Manufacturer\'s Part Number is a unique code determined by the manufacturer for that product.</small>', 'eshop');
            ?>
</label>
		<input type="text" name="basempn" id="basempn" value="<?php 
            echo esc_html($basedata->mpn);
            ?>
" />
		<label for="baseptype"><?php 
            _e('Product type <small>The type of product being offered.</small>', 'eshop');
            ?>
</label>
		<input type="text" name="baseptype" id="baseptype" value="<?php 
            echo esc_html($basedata->ptype);
            ?>
" />
		<label for="baseqty"><?php 
            _e('Quantity', 'eshop');
            ?>
</label>
		<input type="text" name="baseqty" id="baseqty" value="<?php 
            echo esc_html($basedata->qty);
            ?>
" />
	  <label for="basecondition"><?php 
            _e('Condition <small>the condition of this product</small>', 'eshop');
            ?>
</label>
	  <select name="basecondition" id="basecondition">
		<?php 
            //'
            foreach ($currentconditions as $code) {
                if ($basedata->thecondition == '') {
                    if ($code == $eshopoptions['base_condition']) {
                        $sel = ' selected="selected"';
                    } else {
                        $sel = '';
                    }
                } elseif ($code == $eshopoptions['base_condition']) {
                    $sel = ' selected="selected"';
                } else {
                    $sel = '';
                }
                echo '<option value="' . $code . '"' . $sel . '>' . $code . '</option>' . "\n";
            }
            ?>
	  </select>
	  <fieldset><legend><?php 
            _e('Expiration date <small>(or how long a product will be available.)</small>', 'eshop');
            ?>
</legend>
	  <label for="baseexpiration_year"><?php 
            _e('Year', 'eshop');
            ?>
</label>
	  <select name="baseexpiration_year" id="baseexpiration_year">
		<?php 
            // work this out!!!
            if ($basedata->expiry == '') {
                $baseexpiry = $eshopoptions['base_expiry'];
                $basedate = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") + $baseexpiry, date("Y")));
                list($baseexpiration_year, $baseexpiration_month, $baseexpiration_day) = explode('-', $basedate);
            } else {
                list($baseexpiration_year, $baseexpiration_month, $baseexpiration_day) = explode('-', $basedata->expiry);
            }
            for ($i = date('Y'); $i <= date('Y') + 5; $i++) {
                if ($i == $baseexpiration_year) {
                    $sel = ' selected="selected"';
                } else {
                    $sel = '';
                }
                echo '<option value="' . $i . '"' . $sel . '>' . $i . '</option>' . "\n";
            }
            ?>
	  </select>
		<label for="baseexpiration_month"><?php 
            _e('Month', 'eshop');
            ?>
</label>

		  <select name="baseexpiration_month" id="baseexpiration_month">
		<?php 
            for ($i = 1; $i <= 12; $i++) {
                if ($i == $baseexpiration_month) {
                    $sel = ' selected="selected"';
                } else {
                    $sel = '';
                }
                echo '<option value="' . $i . '"' . $sel . '>' . $i . '</option>' . "\n";
            }
            ?>
	  </select>
		<label for="baseexpiration_day"><?php 
            _e('Day', 'eshop');
            ?>
</label>

		  <select name="baseexpiration_day" id="baseexpiration_day">
		<?php 
            for ($i = 1; $i <= 31; $i++) {
                if ($i == $baseexpiration_day) {
                    $sel = ' selected="selected"';
                } else {
                    $sel = '';
                }
                echo '<option value="' . $i . '"' . $sel . '>' . $i . '</option>' . "\n";
            }
            ?>
	  </select>
	  </fieldset>
	  </fieldset>
	  <p class="submit">
	  <input type="submit" name="submit" class="button-primary" value="<?php 
            _e('Update');
            ?>
" />
	</p>
		<?php 
            echo '</form></div>';
        } else {
            ?>
	<div class="wrap">
	<div id="eshopicon" class="icon32"></div><h2><?php 
            _e('Error', 'eshop');
            ?>
</h2>
	<p><?php 
            _e('That product does not exist!', 'eshop');
            ?>
</p>
	</div>
	<?php 
        }
    }
}
 function eshop_excerpt_img($output)
 {
     global $post, $eshopoptions;
     $echo = '';
     if (is_search()) {
         $isaproduct = get_post_meta($post->ID, '_eshop_product', true);
         $w = get_option('thumbnail_size_w');
         $h = get_option('thumbnail_size_h');
         if (has_post_thumbnail($post->ID)) {
             $eimg = get_the_post_thumbnail($post->ID, array($w, $h)) . "\n";
         } else {
             $eimage = eshop_files_directory();
             $eshopnoimage = apply_filters('eshop_no_image', $eimage['1'] . 'noimage.png');
             $eimg = '<img src="' . $eshopnoimage . '" height="' . $h . '" width="' . $w . '" alt="" />' . "\n";
         }
         if ($eshopoptions['search_img'] == 'all') {
             $echo .= $eimg;
         } elseif ($eshopoptions['search_img'] == 'yes' && $isaproduct != '') {
             $echo .= $eimg;
         }
     }
     return $echo . $output;
 }
예제 #5
0
 function eshop_stylesheet()
 {
     global $eshopoptions;
     $eshopurl = eshop_files_directory();
     if (@file_exists(STYLESHEETPATH . '/eshop.css')) {
         $myStyleUrl = get_stylesheet_directory_uri() . '/eshop.css';
         $myStyleFile = STYLESHEETPATH . '/eshop.css';
     } elseif ($eshopoptions['style'] == 'yes') {
         $myStyleUrl = $eshopurl['1'] . 'eshop.css';
         $myStyleFile = $eshopurl['0'] . 'eshop.css';
     }
     if (file_exists($myStyleFile)) {
         wp_register_style('myStyleSheets', $myStyleUrl);
         wp_enqueue_style('myStyleSheets');
     }
 }
 function widget($args, $instance)
 {
     extract($args);
     global $blog_id, $eshopoptions;
     $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     echo $before_widget;
     echo $before_title . $title . $after_title;
     if (is_array($eshopoptions['method'])) {
         $i = 1;
         $replace = array(".");
         $eshopfiles = eshop_files_directory();
         echo "\n" . '<ul class="eshoppaywidget">' . "\n";
         foreach ($eshopoptions['method'] as $k => $eshoppayment) {
             $eshoppayment_text = $eshoppayment;
             $eshoppayment = str_replace($replace, "", $eshoppayment);
             if ($eshoppayment_text == 'cash') {
                 $eshopcash = $eshopoptions['cash'];
                 if ($eshopcash['rename'] != '') {
                     $eshoppayment_text = $eshopcash['rename'];
                 }
             }
             if ($eshoppayment_text == 'bank') {
                 $eshopbank = $eshopoptions['bank'];
                 if ($eshopbank['rename'] != '') {
                     $eshoppayment_text = $eshopbank['rename'];
                 }
             }
             $eshopmi = apply_filters('eshop_merchant_img_' . $eshoppayment, array('path' => $eshopfiles['0'] . $eshoppayment . '.png', 'url' => $eshopfiles['1'] . $eshoppayment . '.png'));
             $eshopmerchantimgpath = $eshopmi['path'];
             $eshopmerchantimgurl = $eshopmi['url'];
             $dims = '';
             if (file_exists($eshopmerchantimgpath)) {
                 $dims = getimagesize($eshopmerchantimgpath);
             }
             echo '<li><img src="' . $eshopmerchantimgurl . '" ' . $dims[3] . ' alt="' . __('Pay via', 'eshop') . ' ' . $eshoppayment_text . '" title="' . __('Pay via', 'eshop') . ' ' . $eshoppayment_text . '" /></li>' . "\n";
             $i++;
         }
         echo "</ul>\n";
     }
     echo $after_widget;
 }
예제 #7
0
 function eshop_action_javascript()
 {
     $eshopajaxcart['addfadein'] = 100;
     $eshopajaxcart['addfadeout'] = 3000;
     $eshopajaxcart['cartcleardelay'] = 1000;
     $eshopajaxcart['cartdelay'] = 750;
     $eshopajaxcart['cartupdate'] = 3000;
     $eshopajaxcart['cartfadeout'] = 50;
     $eshopajaxcart['cartfadein'] = 700;
     //expects an array
     $eshopajaxcart = apply_filters('eshop_ajax_cart', $eshopajaxcart);
     $eshopCartParams = array('addfadein' => $eshopajaxcart['addfadein'], 'addfadeout' => $eshopajaxcart['addfadeout'], 'cartcleardelay' => $eshopajaxcart['cartcleardelay'], 'cartdelay' => $eshopajaxcart['cartdelay'], 'cartupdate' => $eshopajaxcart['cartupdate'], 'cartfadeout' => $eshopajaxcart['cartfadeout'], 'cartfadein' => $eshopajaxcart['cartfadein'], 'adminajax' => get_admin_url() . 'admin-ajax.php');
     $eshopurl = eshop_files_directory();
     wp_register_script('eshop_cart_widget', '' . $eshopurl['1'] . 'eshop-cart.js', array('jquery'));
     wp_enqueue_script('eshop_cart_widget');
     wp_localize_script('eshop_cart_widget', 'eshopCartParams', $eshopCartParams);
 }
예제 #8
0
function eshop_boing($pee, $short = 'no', $postid = '', $isshortcode = 'n')
{
    global $wpdb, $post, $eshopchk, $eshopoptions;
    if ($postid == '') {
        $postid = $post->ID;
    }
    $stkav = get_post_meta($postid, '_eshop_stock', true);
    $eshop_product = maybe_unserialize(get_post_meta($postid, '_eshop_product', true));
    $saleclass = '';
    if (isset($eshop_product['sale']) && $eshop_product['sale'] == 'yes') {
        $saleclass = ' sale';
    }
    $stocktable = $wpdb->prefix . "eshop_stock";
    $uniq = rand();
    if (post_password_required()) {
        return $pee;
    }
    //if the search page we don't want the form!
    //was (!strpos($pee, '[eshop_addtocart'))
    if ($short != 'yes' && strpos($pee, '[eshop_details') === false && (is_single() || is_page()) && isset($eshopoptions['details']['display']) && 'yes' == $eshopoptions['details']['display']) {
        $details = '';
        if (isset($eshop_product['products'])) {
            if ($eshopoptions['details']['show'] != '') {
                $details .= " show='" . esc_attr($eshopoptions['details']['show']) . "'";
            }
            if ($eshopoptions['details']['class'] != '') {
                $details .= " class='" . esc_attr($eshopoptions['details']['class']) . "'";
            }
            if ($eshopoptions['details']['hide'] != '') {
                $details .= " options_hide='" . esc_attr($eshopoptions['details']['hide']) . "'";
            }
            if (isset($eshopoptions['details']['tax']) && $eshopoptions['details']['tax'] != '') {
                $details .= " etax_page='" . esc_attr($eshopoptions['details']['tax']) . "'";
            }
            if ($isshortcode == 'n') {
                $pee .= do_shortcode('[eshop_details' . $details . ']');
            }
        }
    }
    if (strpos($pee, '[eshop_addtocart') === false && (is_single() || is_page() || 'yes' == $eshopoptions['show_forms'])) {
        //need to precheck stock
        if ($postid != '') {
            if (isset($eshopoptions['stock_control']) && 'yes' == $eshopoptions['stock_control']) {
                $anystk = false;
                $stkq = $wpdb->get_results("SELECT option_id, available from {$stocktable} where post_id={$postid}");
                foreach ($stkq as $thisstk) {
                    $stkarr[$thisstk->option_id] = $thisstk->available;
                }
                $opt = $eshopoptions['options_num'];
                for ($i = 1; $i <= $opt; $i++) {
                    $currst = 0;
                    if (isset($stkarr[$i]) && $stkarr[$i] > 0) {
                        $currst = $stkarr[$i];
                    }
                    if ($currst > 0) {
                        $anystk = true;
                        $i = $opt;
                    }
                }
                if ($anystk == false) {
                    $stkav = '0';
                    delete_post_meta($postid, '_eshop_stock');
                }
            }
        }
        $replace = '';
        $stkav = apply_filters('eshop_show_addtocart', $stkav, $postid, $post);
        if ($stkav == '1') {
            $currsymbol = $eshopoptions['currency_symbol'];
            if (isset($eshopoptions['cart_text']) && $eshopoptions['cart_text'] != '' && $short == 'no') {
                if ($eshopoptions['cart_text_where'] == '1') {
                    $replace .= '<p class="eshop-cart-text-above">' . stripslashes($eshopoptions['cart_text']) . '</p>';
                }
            }
            $replace .= '
			<form action="' . get_permalink($eshopoptions['cart']) . '" method="post" class="eshop addtocart' . $saleclass . '" id="eshopprod' . $postid . $uniq . '">
			<fieldset><legend><span class="offset">' . __('Order', 'eshop') . ' ' . stripslashes(esc_attr($eshop_product['description'])) . '</span></legend>';
            $theid = sanitize_file_name($eshop_product['sku']);
            //option sets
            $optsets = $eshop_product['optset'];
            $optsetsecho = $mainoptsecho = '';
            if (is_array($optsets)) {
                $opttable = $wpdb->prefix . 'eshop_option_sets';
                $optnametable = $wpdb->prefix . 'eshop_option_names';
                $optarray = array();
                foreach ($optsets as $foo => $opset) {
                    $qb[] = "(n.optid={$opset} && n.optid=s.optid)";
                }
                $qbs = implode("OR", $qb);
                $optionsetord = apply_filters('eshop_option_set_ordering', 'ORDER BY type, id ASC');
                $myrowres = $wpdb->get_results("select n.optid,n.name as name, n.type, s.name as label, s.price, s.id from {$opttable} as s, \n\t\t\t\t\t{$optnametable} as n where {$qbs} {$optionsetord}");
                $x = 0;
                foreach ($myrowres as $myrow) {
                    $optarray[$myrow->optid]['name'] = $myrow->name;
                    $optarray[$myrow->optid]['optid'] = $myrow->optid;
                    $optarray[$myrow->optid]['type'] = $myrow->type;
                    $optarray[$myrow->optid]['item'][$x]['id'] = $myrow->id;
                    $optarray[$myrow->optid]['item'][$x]['label'] = $myrow->label;
                    $optarray[$myrow->optid]['item'][$x]['price'] = $myrow->price;
                    $x++;
                }
                $enumb = 0;
                if (is_array($optarray)) {
                    foreach ($optarray as $optsets) {
                        switch ($optsets['type']) {
                            case '0':
                                //select
                                $optsetsecho .= "\n" . '<span class="eshop eselect"><label for="exopt' . $optsets['optid'] . $enumb . $uniq . '">' . stripslashes(esc_attr($optsets['name'])) . '</label><select id="exopt' . $optsets['optid'] . $enumb . $uniq . '" name="optset[' . $enumb . '][id]">' . "\n";
                                foreach ($optsets['item'] as $opsets) {
                                    if ($opsets['price'] != '0.00') {
                                        $addprice = sprintf(__(' + %1$s%2$s', 'eshop'), $currsymbol, number_format_i18n($opsets['price'], __('2', 'eshop')));
                                    } else {
                                        $addprice = '';
                                    }
                                    $optsetsecho .= '<option value="' . $opsets['id'] . '">' . stripslashes(esc_attr($opsets['label'])) . $addprice . '</option>' . "\n";
                                }
                                $optsetsecho .= "</select></span>\n";
                                break;
                            case '1':
                                //checkbox
                                $optsetsecho .= "\n" . '<fieldset class="eshop echeckbox"><legend>' . stripslashes(esc_attr($optsets['name'])) . '</legend>' . "\n";
                                $ox = 0;
                                foreach ($optsets['item'] as $opsets) {
                                    $ox++;
                                    if ($opsets['price'] != '0.00') {
                                        $addprice = sprintf(__(' + %1$s%2$s', 'eshop'), $currsymbol, number_format_i18n($opsets['price'], __('2', 'eshop')));
                                    } else {
                                        $addprice = '';
                                    }
                                    $optsetsecho .= '<span><input type="checkbox" value="' . $opsets['id'] . '" id="exopt' . $optsets['optid'] . $enumb . 'i' . $ox . $uniq . '" name="optset[' . $enumb . '][id]" /><label for="exopt' . $optsets['optid'] . $enumb . 'i' . $ox . $uniq . '">' . stripslashes(esc_attr($opsets['label'])) . $addprice . '</label></span>' . "\n";
                                    $enumb++;
                                }
                                $optsetsecho .= "</fieldset>\n";
                                break;
                            case '2':
                                //text
                                foreach ($optsets['item'] as $opsets) {
                                    if ($opsets['price'] != '0.00') {
                                        $addprice = sprintf(__(' + %1$s%2$s', 'eshop'), $currsymbol, number_format_i18n($opsets['price'], __('2', 'eshop')));
                                    } else {
                                        $addprice = '';
                                    }
                                    $optsetsecho .= "\n" . '<span class="eshop etext"><label for="exopt' . $optsets['optid'] . $enumb . $uniq . '">' . stripslashes(esc_attr($opsets['label'])) . '<span>' . $addprice . '</span></label>' . "\n";
                                    $optsetsecho .= '<input type="text" id="exopt' . $optsets['optid'] . $enumb . $uniq . '" name="optset[' . $enumb . '][text]" value="" />' . "\n";
                                    $optsetsecho .= '<input type="hidden" name="optset[' . $enumb . '][id]" value="' . $opsets['id'] . '" />' . "\n";
                                    $optsetsecho .= '<input type="hidden" name="optset[' . $enumb . '][type]" value="' . $optsets['type'] . '" />' . "\n";
                                }
                                $optsetsecho .= "</span>\n";
                                break;
                            case '3':
                                //textarea
                                foreach ($optsets['item'] as $opsets) {
                                    if ($opsets['price'] != '0.00') {
                                        $addprice = sprintf(__(' + %1$s%2$s', 'eshop'), $currsymbol, number_format_i18n($opsets['price'], __('2', 'eshop')));
                                    } else {
                                        $addprice = '';
                                    }
                                    $optsetsecho .= "\n" . '<span class="eshop etextarea"><label for="exopt' . $optsets['optid'] . $enumb . $uniq . '">' . stripslashes(esc_attr($opsets['label'])) . '<span>' . $addprice . '</span></label>' . "\n";
                                    $optsetsecho .= '<textarea id="exopt' . $optsets['optid'] . $enumb . $uniq . '" name="optset[' . $enumb . '][text]" rows="4" cols="40"></textarea>' . "\n";
                                    $optsetsecho .= '<input type="hidden" name="optset[' . $enumb . '][id]" value="' . $opsets['id'] . '" />' . "\n";
                                    $optsetsecho .= '<input type="hidden" name="optset[' . $enumb . '][type]" value="' . $optsets['type'] . '" />' . "\n";
                                }
                                $optsetsecho .= "</span>\n";
                                break;
                        }
                        $enumb++;
                    }
                }
            }
            if ($eshopoptions['options_num'] > 1 && !empty($eshop_product['products']['2']['option']) && !empty($eshop_product['products']['2']['price'])) {
                if (isset($eshop_product['cart_radio']) && $eshop_product['cart_radio'] == '1') {
                    $opt = $eshopoptions['options_num'];
                    $uniq = apply_filters('eshop_uniq', $uniq);
                    $mainoptsecho .= "\n<ul class=\"eshopradio\">\n";
                    for ($i = 1; $i <= $opt; $i++) {
                        $option = $eshop_product['products'][$i]['option'];
                        $price = $eshop_product['products'][$i]['price'];
                        if (isset($eshopoptions['sale_prices']) && $eshopoptions['sale_prices'] == 1 && isset($eshopoptions['sale']) && 'yes' == $eshopoptions['sale'] && isset($eshop_product['products'][$i]['saleprice']) && $eshop_product['products'][$i]['saleprice'] != '' && isset($eshop_product['sale']) && $eshop_product['sale'] == 'yes') {
                            $price = $eshop_product['products'][$i]['saleprice'];
                        }
                        if ($i == '1') {
                            $esel = ' checked="checked"';
                        } else {
                            $esel = '';
                        }
                        $currst = 1;
                        if (isset($eshopoptions['stock_control']) && 'yes' == $eshopoptions['stock_control']) {
                            if (isset($stkarr[$i]) && $stkarr[$i] > 0) {
                                $currst = $stkarr[$i];
                            } else {
                                $currst = 0;
                            }
                        }
                        if ($option != '' && $currst > 0) {
                            if ($price != '0.00') {
                                $mainoptsecho .= '<li><input type="radio" value="' . $i . '" id="eshopopt' . $theid . '_' . $i . $uniq . '" name="option"' . $esel . ' /><label for="eshopopt' . $theid . '_' . $i . $uniq . '">' . sprintf(__('%1$s @ %2$s%3$s', 'eshop'), stripslashes(esc_attr($option)), $currsymbol, number_format_i18n($price, __('2', 'eshop'))) . "</label>\n</li>";
                            } else {
                                $mainoptsecho .= '<li><input type="radio" value="' . $i . '" id="eshopopt' . $theid . '_' . $i . $uniq . '" name="option" /><label for="eshopopt' . $theid . '_' . $i . $uniq . '">' . stripslashes(esc_attr($option)) . '</label>' . "\n</li>";
                            }
                        }
                    }
                    $mainoptsecho .= "</ul>\n";
                    //combine 2 into 1 then extract
                    $filterarray[0] = $mainoptsecho;
                    $filterarray[1] = $eshop_product;
                    $filterarray = apply_filters('eshop_after_radio', $filterarray);
                    $mainoptsecho = $filterarray[0];
                } else {
                    $opt = $eshopoptions['options_num'];
                    $mainoptsecho .= "\n" . '<label for="eopt' . $theid . $uniq . '"><select id="eopt' . $theid . $uniq . '" name="option">';
                    for ($i = 1; $i <= $opt; $i++) {
                        if (isset($eshop_product['products'][$i])) {
                            $option = $eshop_product['products'][$i]['option'];
                            $price = $eshop_product['products'][$i]['price'];
                            if (isset($eshopoptions['sale_prices']) && $eshopoptions['sale_prices'] == 1 && isset($eshopoptions['sale']) && 'yes' == $eshopoptions['sale'] && isset($eshop_product['products'][$i]['saleprice']) && $eshop_product['products'][$i]['saleprice'] != '' && isset($eshop_product['sale']) && $eshop_product['sale'] == 'yes') {
                                $price = $eshop_product['products'][$i]['saleprice'];
                            }
                            $currst = 1;
                            if (isset($eshopoptions['stock_control']) && 'yes' == $eshopoptions['stock_control']) {
                                if (isset($stkarr[$i]) && $stkarr[$i] > 0) {
                                    $currst = $stkarr[$i];
                                } else {
                                    $currst = 0;
                                }
                            }
                            if ($option != '' && $currst > 0) {
                                if ($price != '0.00') {
                                    $mainoptsecho .= '<option value="' . $i . '">' . sprintf(__('%1$s @ %2$s%3$s', 'eshop'), stripslashes(esc_attr($option)), $currsymbol, number_format_i18n($price, __('2', 'eshop'))) . '</option>' . "\n";
                                } else {
                                    $mainoptsecho .= '<option value="' . $i . '">' . stripslashes(esc_attr($option)) . '</option>' . "\n";
                                }
                            }
                        }
                    }
                    $mainoptsecho .= '</select></label>';
                }
            } else {
                $option = $eshop_product['products']['1']['option'];
                $price = $eshop_product['products']['1']['price'];
                if (isset($eshopoptions['sale_prices']) && $eshopoptions['sale_prices'] == '1' && isset($eshopoptions['sale']) && 'yes' == $eshopoptions['sale'] && isset($eshop_product['products']['1']['saleprice']) && $eshop_product['products']['1']['saleprice'] != '' && isset($eshop_product['sale']) && $eshop_product['sale'] == 'yes') {
                    $price = $eshop_product['products']['1']['saleprice'];
                }
                $currst = 1;
                if (isset($eshopoptions['stock_control']) && 'yes' == $eshopoptions['stock_control']) {
                    if (isset($stkarr[1]) && $stkarr[1] > 0) {
                        $currst = $stkarr[1];
                    }
                }
                $mainoptsecho .= '<input type="hidden" name="option" value="1" />';
                if ($currst > 0) {
                    if ($price != '0.00') {
                        $mainoptsecho .= '
						<span class="sgloptiondetails"><span class="sgloption">' . stripslashes(esc_attr($option)) . '</span> <span class="sglprice">' . sprintf(__('@ %1$s%2$s', 'eshop'), $currsymbol, number_format_i18n($price, __('2', 'eshop'))) . '</span></span>
						';
                    } else {
                        $mainoptsecho .= '
						<span class="sgloptiondetails"><span class="sgloption">' . stripslashes(esc_attr($option)) . '</span></span>
						';
                    }
                }
            }
            /*
             default is set to true to show options sets followed by manin options
             change to false to show main option followed by option sets
            */
            $eshopoptionsorder = apply_filters('eshop_options_order', true);
            if ($eshopoptionsorder) {
                $replace .= $optsetsecho . $mainoptsecho;
            } else {
                $replace .= $mainoptsecho . $optsetsecho;
            }
            $addqty = 1;
            if (isset($eshopoptions['min_qty']) && $eshopoptions['min_qty'] != '') {
                $addqty = $eshopoptions['min_qty'];
            }
            if ($short == 'yes') {
                $replace .= '<input type="hidden" name="qty" value="' . $addqty . '" />';
            } else {
                $replace .= '<label for="qty' . $theid . $uniq . '" class="qty">' . __('<abbr title="Quantity">Qty</abbr>:', 'eshop') . '</label>
				<input type="text" value="' . $addqty . '" id="qty' . $theid . $uniq . '" maxlength="3" size="3" name="qty" class="iqty" />';
            }
            $replace .= '
			<input type="hidden" name="pclas" value="' . $eshop_product['shiprate'] . '" />
			<input type="hidden" name="pname" value="' . stripslashes(esc_attr($eshop_product['description'])) . '" />
			<input type="hidden" name="pid" value="' . $eshop_product['sku'] . '" />
			<input type="hidden" name="purl" value="' . get_permalink($postid) . '" />
			<input type="hidden" name="postid" value="' . $postid . '" />
			<input type="hidden" name="eshopnon" value="set" />';
            $replace .= wp_nonce_field('eshop_add_product_cart', '_wpnonce' . $uniq, true, false);
            if ($eshopoptions['addtocart_image'] == 'img') {
                $eshopfiles = eshop_files_directory();
                $imgloc = apply_filters('eshop_theme_addtocartimg', $eshopfiles['1'] . 'addtocart.png');
                $replace .= '<input class="buttonimg eshopbutton" src="' . $imgloc . '" value="' . __('Add to Cart', 'eshop') . '" title="' . __('Add selected item to your shopping basket', 'eshop') . '" type="image" />';
            } else {
                $replace .= '<input class="button eshopbutton" value="' . __('Add to Cart', 'eshop') . '" title="' . __('Add selected item to your shopping basket', 'eshop') . '" type="submit" />';
            }
            $replace .= '<div class="eshopajax"></div></fieldset>
			</form>';
            if (isset($eshopoptions['cart_text']) && $eshopoptions['cart_text'] != '' && $short == 'no') {
                if ($eshopoptions['cart_text_where'] == '2') {
                    $replace .= '<p class="eshop-cart-text-below">' . stripslashes($eshopoptions['cart_text']) . '</p>';
                }
            }
            $pee = $pee . $replace;
        } elseif (isset($currst) && $currst <= 0 && is_array($eshop_product)) {
            $replace = '<p class="eshopnostock"><span>' . $eshopoptions['cart_nostock'] . '</span></p>';
            $pee = $pee . $replace;
        }
        return $pee;
    } else {
        return $pee;
    }
}
function eshop_show_payments()
{
    global $eshopoptions;
    $echo = '';
    eshop_cache();
    if (is_array($eshopoptions['method'])) {
        $i = 1;
        $replace = array(".");
        $eshopfiles = eshop_files_directory();
        $echo .= "\n" . '<ul class="eshop eshoppayoptions">' . "\n";
        foreach ($eshopoptions['method'] as $k => $eshoppayment) {
            $eshoppayment_text = $eshoppayment;
            $eshoppayment = str_replace($replace, "", $eshoppayment);
            if ($eshoppayment_text == 'cash') {
                $eshopcash = $eshopoptions['cash'];
                if ($eshopcash['rename'] != '') {
                    $eshoppayment_text = $eshopcash['rename'];
                }
            }
            if ($eshoppayment_text == 'bank') {
                $eshopbank = $eshopoptions['bank'];
                if ($eshopbank['rename'] != '') {
                    $eshoppayment_text = $eshopbank['rename'];
                }
            }
            $eshopmi = apply_filters('eshop_merchant_img_' . $eshoppayment, array('path' => $eshopfiles['0'] . $eshoppayment . '.png', 'url' => $eshopfiles['1'] . $eshoppayment . '.png'));
            $eshopmerchantimgpath = $eshopmi['path'];
            $eshopmerchantimgurl = $eshopmi['url'];
            $dims = array('3' => '');
            if (file_exists($eshopmerchantimgpath)) {
                $dims = getimagesize($eshopmerchantimgpath);
            }
            $echo .= '<li><img src="' . $eshopmerchantimgurl . '" ' . $dims[3] . ' alt="' . __('Pay via', 'eshop') . ' ' . $eshoppayment_text . '" title="' . __('Pay via', 'eshop') . ' ' . $eshoppayment_text . '" /></li>' . "\n";
            $i++;
        }
        $echo .= "</ul>\n";
    }
    return $echo;
}
예제 #10
0
 function show_img($eshoppayment)
 {
     global $eshopoptions;
     $replace = array(".");
     $eshopfiles = eshop_files_directory();
     $eshoppayment_text = $eshoppayment;
     $eshoppayment = str_replace($replace, "", $eshoppayment);
     if ($eshoppayment_text == 'cash' && isset($eshopoptions['cash'])) {
         $eshopcash = $eshopoptions['cash'];
         if ($eshopcash['rename'] != '') {
             $eshoppayment_text = $eshopcash['rename'];
         }
     }
     if ($eshoppayment_text == 'bank' && isset($eshopoptions['bank'])) {
         $eshopbank = $eshopoptions['bank'];
         if ($eshopbank['rename'] != '') {
             $eshoppayment_text = $eshopbank['rename'];
         }
     }
     $eshopmi = apply_filters('eshop_merchant_img_' . $eshoppayment, array('path' => $eshopfiles['0'] . $eshoppayment . '.png', 'url' => $eshopfiles['1'] . $eshoppayment . '.png'));
     $eshopmerchantimgpath = $eshopmi['path'];
     $eshopmerchantimgurl = $eshopmi['url'];
     $dims[3] = '';
     if (file_exists($eshopmerchantimgpath)) {
         $dims = getimagesize($eshopmerchantimgpath);
     }
     echo '<p class="eshopgateway"><img src="' . $eshopmerchantimgurl . '" ' . $dims[3] . ' alt="' . $eshoppayment_text . '" title="' . $eshoppayment_text . '" /></p>' . "\n";
 }
예제 #11
0
function eshop_form_admin_style()
{
    //make sure options exist for the style page
    //config options
    $eshopurl = eshop_files_directory();
    $styleFile = $eshopurl['0'] . 'eshop.css';
    $style = eshop_process_style($styleFile);
    $eshopoptions = get_option('eshop_plugin_settings');
    if (!is_writeable($styleFile)) {
        echo ' <div id="message" class="error fade"><p>' . __('<strong>Warning!</strong> The css file is not currently editable/writable! File permissions must first be changed.', 'eshop') . '</p>
	   	</div>' . "\n";
    }
    ?>
<div class="wrap">
<div id="eshopicon" class="icon32"></div><h2><?php 
    _e('eShop Styles', 'eshop');
    ?>
</h2>
<?php 
    eshop_admin_mode();
    ?>
</div>
<div class="wrap">
<h2><?php 
    _e('Default Style', 'eshop');
    ?>
</h2>
<?php 
    if (@file_exists(get_stylesheet_directory() . '/eshop.css')) {
        echo '<p>';
        _e('Your active theme has an eshop style sheet, eshop.css, and will be used in preference to the default style below. Therefore changes made via the style editor below will not show on your site.', 'eshop');
        echo '</p>';
    } else {
        ?>
<p><?php 
        _e('Default style is used by default. You can edit this via the editor below, or choose not to use it.', 'eshop');
        ?>
</p>
<form action="themes.php?page=eshop-style.php" method="post" id="style_form" name="style">
 <fieldset>
  <legend><?php 
        _e('Use Default Style', 'eshop');
        ?>
</legend>
  <?php 
        if ($eshopoptions['style'] == 'yes') {
            $yes = ' checked="checked"';
            $no = '';
        } else {
            $no = ' checked="checked"';
            $yes = '';
        }
        ?>
  <input type="radio" id="usestyle" name="usestyle" value="yes"<?php 
        echo $yes;
        ?>
 /><label for="usestyle"><?php 
        _e('Yes', 'eshop');
        ?>
</label> 
  <input type="radio" id="nostyle" name="usestyle" value="no"<?php 
        echo $no;
        ?>
 /><label for="nostyle"><?php 
        _e('No', 'eshop');
        ?>
</label>
  <p class="submit eshop"><input type="submit" value="<?php 
        _e('Amend', 'eshop');
        ?>
" name="submit" /></p>

</fieldset>
</form>
<?php 
    }
    //check for new css
    $plugin_dir = WP_PLUGIN_DIR;
    $dirs = wp_upload_dir();
    $upload_dir = $dirs['basedir'];
    $eshop_goto = $upload_dir . '/eshop_files/eshop.css';
    $eshop_from = $plugin_dir . '/eshop/files/eshop.css';
    $eshopver = split('\\.', ESHOP_VERSION);
    $left_string = file_get_contents($eshop_from, true);
    $right_string = file_get_contents($eshop_goto, true);
    ?>
</div>
<div class="wrap">
<h2><?php 
    _e('Style Editor', 'eshop');
    ?>
</h2>
 <p><?php 
    _e('Use this simple <abbr><span class="abbr" title="Cascading Style Sheet">CSS</span></abbr> file editor to modify the default style sheet file.', 'eshop');
    ?>
</p>
 <form method="post" action="themes.php?page=eshop-style.php" id="edit_box">
  <fieldset>
   <legend><?php 
    _e('Style File Editor.', 'eshop');
    ?>
</legend>
   <label for="stylebox"><?php 
    _e('Edit Style', 'eshop');
    ?>
</label><br />
	<textarea rows="20" cols="80" id="stylebox" name="cssFile"><?php 
    if (!is_file($styleFile)) {
        $error = 1;
    }
    if (!isset($error) && filesize($styleFile) > 0) {
        $f = "";
        $f = fopen($styleFile, 'r');
        $file = fread($f, filesize($styleFile));
        echo $file;
        fclose($f);
    } else {
        _e('Sorry. The file you are looking for could not be found', 'eshop');
    }
    ?>
</textarea>
   <p class="submit eshop"><input type="submit" class="button-primary" value="<?php 
    _e('Update Style', 'eshop');
    ?>
" name="submit" /></p>
  </fieldset>
</form>
</div>
	<?php 
    $left_string = normalize_whitespace($left_string);
    $right_string = normalize_whitespace($right_string);
    if (isset($_GET['diff'])) {
        echo '<div class="wrap" id="diff">';
        echo wp_text_diff($right_string, $left_string, array('title' => __('Comparing Current Style with latest installed version of eShop', 'eshop'), 'title_right' => __('Latest(from plugin)', 'eshop'), 'title_left' => __('Current (in use)', 'eshop')));
        echo '</div>';
    } elseif (trim($left_string) != trim($right_string)) {
        echo '<div class="wrap">';
        echo '<p>' . __('There may have been updates to the style.', 'eshop') . ' <a href="themes.php?page=eshop-style.php&amp;diff#diff">' . __('Compare Current Style with latest installed version of eShop.', 'eshop') . '</a></p>';
        echo '</div>';
    } else {
        echo '<div class="wrap">';
        echo '<p>' . __('Your CSS matches that included with eShop.', 'eshop') . '</p>';
        echo '</div>';
    }
}
예제 #12
0
                         if ($subfile != '.' && $subfile != '..') {
                             unlink($subdloaddir . $subfile);
                         }
                     }
                 }
                 rmdir($subdloaddir);
             } else {
                 unlink($dloaddir . $file);
             }
         }
     }
     closedir($handle);
     rmdir($dloaddir);
     echo '<li>' . __('Files uploaded via the plugin -  deleted', 'eshop') . '</li>';
 }
 $filedir = eshop_files_directory();
 if ($handle = opendir($filedir[0])) {
     // This is the correct way to loop over the directory. //
     while (false !== ($file = readdir($handle))) {
         if ($file != '.' && $file != '..') {
             unlink($filedir[0] . $file);
         }
     }
     closedir($handle);
     rmdir($filedir[0]);
     echo '<li>' . __('eShop template files deleted', 'eshop') . '</li>';
 }
 //unregister widgets
 wp_unregister_sidebar_widget('eshop_widget');
 wp_unregister_sidebar_widget('eshop_pay_widget');
 wp_unregister_sidebar_widget('eshop_products_widget');