Exemple #1
0
 public function set_express_checkout($app, $cart)
 {
     $paypal_data = '';
     $i = $subtotal = $total = 0;
     foreach ($cart['cart_items'] as $row) {
         $price = \Helpers\Util::get_just_price($row['price'], $row['sale_price']);
         $paypal_data .= '&L_PAYMENTREQUEST_0_QTY' . $i . '=' . urlencode($row['quantity']);
         $paypal_data .= '&L_PAYMENTREQUEST_0_AMT' . $i . '=' . urlencode(number_format($price, 2));
         $paypal_data .= '&L_PAYMENTREQUEST_0_NAME' . $i . '=' . urlencode($row['name']);
         $paypal_data .= '&L_PAYMENTREQUEST_0_NUMBER' . $i . '=' . urlencode($row['id']);
         $subtotal = $price * $row['quantity'];
         $total = $total + $subtotal;
         $i += 1;
     }
     $padata = '&PAYMENTREQUEST_0_PAYMENTACTION=Sale' . '&PAYMENTREQUEST_0_CURRENCYCODE=' . urlencode('USD') . '&PAYMENTREQUEST_0_AMT=' . urlencode(number_format($cart['total'], 2)) . '&PAYMENTREQUEST_0_TAXAMT=' . urlencode(number_format($cart['tax'], 2)) . '&PAYMENTREQUEST_0_ITEMAMT=' . urlencode(number_format($total, 2)) . '&ALLOWNOTE=1' . $paypal_data . '&RETURNURL=' . urlencode($app->view()->url_secure('/shop/expresscheckout/return')) . '&CANCELURL=' . urlencode($app->view()->url_secure('/shop/expresscheckout/cancel'));
     $httpParsedResponseAr = $this->pp_http_post('SetExpressCheckout', $padata);
     if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
         $paypalmode = $this->config['paypal.environment'] == 'sandbox' ? '.sandbox' : '';
         //Redirect user to PayPal store with Token received.
         $paypalurl = 'https://www' . $paypalmode . '.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $httpParsedResponseAr["TOKEN"] . '';
         header('Location: ' . $paypalurl);
         exit;
     } else {
         throw new \Exception('SetExpressCheckout failed: ' . print_r($httpParsedResponseAr, true));
     }
 }
Exemple #2
0
 public static function parse_wish_list_items($wish_list_items)
 {
     $subtotal = 0;
     $ids = array();
     foreach ($wish_list_items as $row) {
         $ids[] = $row['id'];
         $price = \Helpers\Util::get_just_price($row['price'], $row['sale_price']);
         $subtotal += $price * $row['quantity'];
     }
     $count = count($wish_list_items);
     $tax = $subtotal * 0.07000000000000001;
     // tax = 7%
     $total = $subtotal + $tax;
     return array('count' => $count, 'subtotal' => $subtotal, 'total' => $total, 'tax' => $tax, 'ids' => implode(',', $ids), 'wish_list_items' => $wish_list_items);
 }
Exemple #3
0
function add_to_wish_list($app, $db, $params)
{
    if (isset($params['id'], $params['attributes'])) {
        $pid = filter_var($params['id'], FILTER_VALIDATE_INT, array('min_range' => 1)) ? $params['id'] : NULL;
        if (empty($params['attributes']) || $params['attributes'] === '0') {
            // product don't have attributes
            $attributes = NULL;
        } elseif ($params['attributes'] === '1') {
            // product needs attributes
            $app->flash('info', 'You need to choose the attributes of your product before adding it to your Wish List.');
            $category = \Data\ProductsRepository::get_category($db, $pid);
            $app->redirect($app->view()->url('/products/' . $category . '/' . $pid));
        } else {
            // actual attributes string
            $attributes = $params['attributes'];
        }
    }
    if (isset($pid, $params['action']) && $params['action'] == 'add') {
        $stmt = \Data\WishListRepository::add_to_wish_list($db, $_SESSION['user_id'], $pid, 1, $attributes);
        $app->flash('info', 'Your Wish List have been updated. A new product have been added.');
        $app->redirect($app->view()->url('/shop/wishlist'));
    } elseif (isset($pid, $params['action']) && $params['action'] == 'remove') {
        $stmt = \Data\WishListRepository::remove_from_wish_list($db, $_SESSION['user_id'], $pid, $attributes);
        $app->flash('info', 'Your Wish List have been updated. The selected product have been removed.');
        $app->redirect($app->view()->url('/shop/wishlist'));
    } elseif (isset($pid, $params['action'], $params['qty']) && $params['action'] == 'move') {
        $qty = filter_var($params['qty'], FILTER_VALIDATE_INT, array('min_range' => 1)) ? $params['qty'] : 1;
        $stmt = \Data\WishListRepository::remove_from_wish_list($db, $_SESSION['user_id'], $pid, $attributes);
        $stmt = \Data\CartRepository::add_to_cart($db, $_SESSION['user_id'], $pid, $qty, $attributes);
        $app->flash('info', 'Your Wish List have been updated. The product selected have been moved to your Cart.');
        $app->redirect($app->view()->url('/shop/wishlist'));
    } elseif (isset($params['action']) && $params['action'] == 'clear') {
        $stmt = \Data\WishListRepository::clear_wish_list($db, $_SESSION['user_id']);
        $app->flash('info', 'Your Wish List have been updated. Your Wish List is now empty.');
        $app->redirect($app->view()->url('/shop/wishlist'));
    } else {
        // show Wish List
        $wish_list_items = \Data\WishListRepository::get_wish_list_contents($db, $_SESSION['user_id']);
        $wish_list = NULL;
        if ($wish_list_items && count($wish_list_items)) {
            $wish_list = \Helpers\Util::parse_wish_list_items($wish_list_items);
        }
        $app->view()->set_template('layouts/basic.php');
        $app->render('shop/wishlist.php', array('page_title' => 'Your WishList', 'wish_list' => $wish_list));
    }
}
 public function post_upload()
 {
     $path = Input::hasFile('subject');
     return Response::json($path ? "true" : "false");
     // return View::make('mobile.pages.index')->nest('main', $path )->with('id', 'results');
     $rules = array('subject' => 'required|image');
     //Validate input
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         return Redirect::back()->with_errors($validation)->with_input();
     }
     $url = array();
     //save files if exists
     foreach (array('subject') as $image) {
         // if( File::exists(Input::file($image.'.tmp_name')) ){
         if (Input::hasFile($image)) {
             $name = Input::file($image)->getClientOriginalName();
             $ext = strtolower(Input::file($image)->getClientOriginalExtension());
             $url[$image] = $this->image_url . '/' . $image . "." . $ext;
             Input::file($image)->move($this->upload_path, $image . "." . $ext);
         }
     }
     //end foreach
     //analyze images submitted
     $litmus = $this->litmus;
     if (isset($url['subject'])) {
         $litmus->set_subject_url($url['subject']);
     }
     if (Input::has('palette_id')) {
         $litmus->set_palette_id(Input::get('palette_id'));
     }
     $response = $litmus->get();
     if ($response->status == 'error') {
         echo $response->message;
         exit;
     }
     //recursive function for outputting a heirarchial data tree
     $string = "<ul>" . Util::recursiveTree($response) . "</ul>";
     $data = array();
     $data['title'] = "Image Analysis";
     $data['lead'] = "Response from Litmus API";
     $data['code'] = $string;
     $data['response'] = $response;
     return View::make('mockup.pages.result', $data);
 }
Exemple #5
0
 public function call()
 {
     $app = Slim::getInstance();
     $this->app->container->singleton(__NAMESPACE__, function () {
         return $this;
     });
     // make them available for other classes */
     $hook = function ($app, $settings) {
         $plugin = $this->app->container->get(__NAMESPACE__);
         return function () use($app, $plugin, $settings) {
             echo $plugin->google($settings->ga, \helpers\Util::host());
         };
     };
     if (isset($this->settings) && isset($this->settings->ga)) {
         $app->hook('script', $hook($app, $this->settings));
     }
     $this->next->call();
 }
Exemple #6
0
 public function call()
 {
     $app = Slim::getInstance();
     $this->app->container->singleton(__NAMESPACE__, function () {
         return $this;
     });
     // make them available for other classes */
     $hook = function ($app) {
         $plugin = $app->container->get(__NAMESPACE__);
         return function () use($app, $plugin) {
             $app->page->sitename = $app->config('theme')->sitename;
             $app->page->image = $plugin->search($app->page->parent, 'image');
             $app->page->share = $plugin->search($app->page->parent, 'share');
             $app->page->seo_title = $plugin->search($app->page->parent, 'seo_title');
             $app->page->url = $app->request()->getUrl() . $app->request()->getScriptName() . '/' . $app->config('language') . $app->request()->getResourceUri();
             $page = $app->page->get_array();
             $page['image'] = $app->request->getUrl() . \helpers\Util::to($page['image']);
             $meta = $plugin->facebook();
             echo $plugin->replace($page, $meta);
         };
     };
     $script = function ($app) {
         $plugin = $app->container->get(__NAMESPACE__);
         return function () use($app, $plugin) {
             echo $plugin->facebook_embed($this->settings->id);
         };
     };
     $body = function ($app) {
         $plugin = $app->container->get(__NAMESPACE__);
         return function () use($app, $plugin) {
             echo '<div id="fb-root"></div>';
         };
     };
     $app->hook('header', $hook($app));
     if (isset($this->settings) && isset($this->settings->id) && $this->settings->id != '') {
         $app->hook('script', $script($app));
         $app->hook('body', $body($app));
     }
     $app->applyHook('front.plugin.social', $this->settings);
     $this->next->call();
 }
Exemple #7
0
            echo $this->url('/products/' . $rp['cname'] . '/' . $rp['id']);
            ?>
" class="link tip" title="View Detail"></a>&nbsp;
                </p>
              </article>
            </div>
          </div>
          <h3><a href="<?php 
            echo $this->url('/products/accessories/' . $rp['id']);
            ?>
"><?php 
            echo $rp['name'];
            ?>
</a></h3>
          <span>$<?php 
            echo \Helpers\Util::get_just_price($rp['price'], $rp['sale_price']);
            ?>
</span>
        </div>
      <?php 
        }
        ?>
    </div>
  <?php 
    }
    ?>

  <div style="clear:both; display:block; height:40px"></div>
<?php 
} else {
    ?>
Exemple #8
0
 /**
  * init shortcodes
  */
 protected function addShortCodes()
 {
     $handle_args = function ($arg, $cb) {
         $id = isset($arg['id']) ? $arg['id'] : (isset($arg['name']) ? $arg['name'] : '');
         $label = isset($arg['label']) ? $arg['label'] : '';
         $value = isset($arg['value']) ? $arg['value'] : '';
         $required = isset($arg['required']) ? $arg['required'] : false;
         if (isset($arg['label'])) {
             unset($arg['label']);
         }
         return $cb($id, $label, $value, $required, $arg);
     };
     \helpers\Util::register_shortcode('submit', function ($arg) {
         $arg['type'] = 'submit';
         $arg['class'] = 'button ' . (isset($arg['class']) ? $arg['class'] : '');
         return \helpers\html::input('', $arg);
     });
     \helpers\Util::register_shortcode('button', function ($arg) {
         $arg['type'] = 'button';
         return \helpers\html::input('', $arg);
     });
     \helpers\Util::register_shortcode('label', function ($arg) use($handle_args) {
         return $handle_args($arg, function ($id, $label, $value, $required, $arg) {
             return '<label for="' . $id . '">' . $label . ($required && $label != '' ? " *" : "") . '</label>';
         });
     });
     \helpers\Util::register_shortcode('text', function ($arg) use($handle_args) {
         $arg['type'] = isset($arg['type']) ? $arg['type'] : 'text';
         return $handle_args($arg, function ($id, $label, $value, $required, $arg) {
             $el = '';
             $el .= '<p class="ui">';
             $el .= '    <label for="' . $id . '">' . $label . ($required && $label != '' ? " *" : "") . '</label>';
             $el .= \helpers\html::input($value, $arg);
             $el .= '</p>';
             return $el;
         });
     });
     \helpers\Util::register_shortcode('select', function ($arg) use($handle_args) {
         $options = explode(',', $arg['options']);
         array_walk($options, function (&$v, $k) {
             $v = '<option>' . $v . '</option>';
         });
         return $handle_args($arg, function ($id, $label, $value, $required, $arg) use($options) {
             $el = '';
             $el .= '<p class="ui">';
             $el .= '    <label for="' . $id . '">' . $label . ($required && $label != '' ? " *" : "") . '</label>';
             $el .= '    <select name="' . $id . '" id="' . $id . '" required="' . $required . '">' . implode($options) . '</select>';
             $el .= '</p>';
             return $el;
         });
     });
     \helpers\Util::register_shortcode('radio', function ($arg) use($handle_args) {
         $arg['type'] = 'radio';
         return $handle_args($arg, function ($id, $label, $value, $required, $arg) {
             $el = '';
             $el .= '<p class="ui radio">';
             $el .= \helpers\html::input($value, $arg);
             $el .= '    <label for="' . $id . '">' . $label . '</label>';
             $el .= '</p>';
             return $el;
         });
     });
     \helpers\Util::register_shortcode('checkbox', function ($arg) use($handle_args) {
         $arg['type'] = 'checkbox';
         return $handle_args($arg, function ($id, $label, $value, $required, $arg) {
             $el = '';
             $el .= '<p class="ui checkbox">';
             $el .= \helpers\html::input($value, $arg);
             $el .= '    <label for="' . $id . '">' . $label . '</label>';
             $el .= '</p>';
             return $el;
         });
     });
     \helpers\Util::register_shortcode('form', function ($arg) use($handle_args) {
         $form = $this->_actionGetForm($arg['id']);
         return '<form id="form_' . $arg['id'] . '" method="post" action="' . \helpers\Location::to('form/' . $arg['id']) . '">
                     <input type="hidden" name="csrf_key" value="' . $_SESSION['csrf_token'] . '">
                     <input type="hidden" name="form" value="' . $arg['id'] . '">
                     ' . \helpers\Util::parse_shortcode($form['page_translation']['content']) . '
                 </form>';
     });
 }
        }
    } else {
        $pathInfo = $env['PATH_INFO'] . (substr($env['PATH_INFO'], -1) !== '/' ? '/' : '');
        // extract lang from PATH_INFO
        foreach ($availableLangs as $availableLang) {
            $match = '/' . $availableLang;
            if (strpos($pathInfo, $match . '/') === 0) {
                $lang = $availableLang;
                $env['PATH_INFO'] = substr($env['PATH_INFO'], strlen($match));
                if (strlen($env['PATH_INFO']) == 0) {
                    $env['PATH_INFO'] = '/';
                }
            }
        }
    }
    $base_url = $config['base_url'];
    if ($app->environment()['slim.url_scheme'] == 'https') {
        define('BASE_URL', str_replace('http', 'https', $base_url));
    } else {
        define('BASE_URL', $base_url);
    }
    $uid = \Helpers\User::user_id();
    $cart_items = \Data\CartRepository::get_shopping_cart_contents($db, $uid);
    if ($cart_items && count($cart_items)) {
        $cart = \Helpers\Util::parse_cart_items($cart_items);
    }
    $app->view()->setLang($lang);
    $app->view()->setAvailableLangs($availableLangs);
    $app->view()->setPathInfo($env['PATH_INFO']);
    $app->view()->appendData(array('page_title' => NULL, 'cart' => isset($cart) ? $cart : NULL, 'db' => $db));
});
        echo $this->url('/products/' . $row['cname'] . '/' . $row['id']);
        ?>
"><?php 
        echo $row['name'];
        ?>
</a></td>
        <td class="quantity"><?php 
        echo $row['quantity'];
        ?>
</td>
        <td class="price">$<?php 
        echo \Helpers\Util::get_just_price($row['price'], $row['sale_price']);
        ?>
</td>
        <td class="total">$<?php 
        echo number_format($row['quantity'] * \Helpers\Util::get_just_price($row['price'], $row['sale_price']), 2);
        ?>
</td>
      </tr>
    <?php 
    }
    ?>
  </table>
    <div class="contentbox">
      <div class="cartoptionbox one-half first">
      <?php 
    if (isset($cart['messages']) && count($cart['messages'])) {
        echo '<table class="alltotal">';
        foreach ($cart['messages'] as $message) {
            echo '<tr><td><span>' . $message . '</span></td></tr>';
        }
Exemple #11
0
          <img height="150" width="150" src="<?php 
        echo $this->uploads_small($n['image']);
        ?>
" alt="" />
          <span><a title="<?php 
        echo $n['name'];
        ?>
" href="<?php 
        echo $this->url('/products/' . $n['cname'] . '/' . $n['id']);
        ?>
"><?php 
        echo \Helpers\Util::safe_truncate($n['name'], 30);
        ?>
</a><br>
          <?php 
        echo \Helpers\Util::get_price_homepage($n['price'], $n['sale_price']);
        ?>
</span>
          <span class="new">New</span>
            <ul>
              <li><a href="<?php 
        echo $this->url('/products/' . $n['cname'] . '/' . $n['id']);
        ?>
" class="link tip" title="View Details">View Details</a></li>
              <?php 
        if ($n['cname'] == 'kits') {
            ?>
                <li><a href="<?php 
            echo $this->url('/shop/cart?action=add&id=' . $n['id'] . '&attributes=1');
            ?>
" class="cart tip" title="Add to Cart">Cart</a></li>
Exemple #12
0
 static function children($page)
 {
     $children = null;
     if (is_numeric($page)) {
         $p = self::_findPage($page);
         if ($p) {
             $page = $p;
         }
     } else {
         $Slim = Slim::getInstance();
         $page = $Slim->page;
     }
     if ($page->hasChildren()) {
         $children = $page->children()->find_many();
         \helpers\Util::sort_pages($children, 'sort');
         return array_map(function ($model) {
             $m = $model->get_array();
             if ($model->hasChildren()) {
                 $m['children'] = self::children($model->id);
             }
             return $m;
         }, $children);
     }
     return null;
 }
Exemple #13
0
        echo Html::script(Location::js('components/validate.js'));
        echo Html::script(Location::js('components/sticky.js'));
        echo Html::script(Location::js('application-build.js'));
    } else {
        echo Html::script(Location::js('build.min.js'));
    }
}
function include_style()
{
    global $app;
    if ($app->getMode() != 'production') {
        echo Html::style(Location::css('build.css'));
        echo Html::style(Location::to('bower_components/components-font-awesome/css/font-awesome.css'));
        echo Html::style(Location::to('bower_components/formstone/dist/css/background.css'));
        echo Html::style(Location::to('bower_components/formstone/dist/css/navigation.css'));
        echo Html::style(Location::to('bower_components/formstone/dist/css/carousel.css'));
        //echo Html::style( Location::to('bower_components/formstone/dist/css/checkbox.css') );
        //echo Html::style( Location::to('bower_components/formstone/dist/css/dropdown.css') );
    } else {
        echo Html::style(Location::css('build.min.css'));
    }
}
$app->hook('header', function () {
    echo include_style();
});
$app->hook('script', function () use($app) {
    echo include_scripts();
});
\helpers\Util::register_shortcode('test', function ($prm, $cnt) {
    return ', ' . $prm['a'] . ', ' . $prm['b'];
});
Exemple #14
0
          <em>Category: <a href="#"><?php 
    echo ucfirst($row['cname']);
    ?>
</a></em><br />
          <span><?php 
    echo \Helpers\Util::get_stock_status($row['stock']);
    ?>
</span><br />
          <span><?php 
    echo \Helpers\Util::safe_truncate($row['description'], 200);
    ?>
</span>
        </section>
        <section class="right">
          <?php 
    echo \Helpers\Util::get_price($row['price'], $row['sale_price']);
    ?>
          <ul class="menu-button">
            <?php 
    if ($row['cname'] == 'kits') {
        ?>
              <li><a href="<?php 
        echo $this->url('/shop/cart?action=add&id=' . $row['id'] . '&attributes=1');
        ?>
" class="cart tip" title="Add to Cart"></a></li>
              <li><a href="<?php 
        echo $this->url('/shop/wishlist?action=add&id=' . $row['id'] . '&attributes=1');
        ?>
" class="wishlist tip" title="Add to Wishlist"></a></li>
            <?php 
    } else {
Exemple #15
0
          <h3><a href="<?php 
        echo $this->url('/products/' . $b['cname'] . '/' . $b['id']);
        ?>
" title="<?php 
        echo $b['name'];
        ?>
"><?php 
        echo \Helpers\Util::safe_truncate($b['name'], 30);
        ?>
</a></h3>
          <small>$<?php 
        echo \Helpers\Util::get_just_price($b['price'], $b['sale_price']);
        ?>
</small><br />
          <small><?php 
        echo \Helpers\Util::get_stock_status($b['stock']);
        ?>
</small>
        </div>
      <?php 
    }
    ?>
  <?php 
} else {
    ?>
    ...
  <?php 
}
?>
  </div><!--end:side-->