コード例 #1
0
ファイル: Settings.php プロジェクト: dioscouri/f3-shop
 public function notifications()
 {
     $this->settings_route = '/admin/shop/settings/notifications';
     switch ($this->app->get('VERB')) {
         case "POST":
         case "post":
             $data = $this->app->get('REQUEST');
             $__emails = explode(",", \Dsc\ArrayHelper::get($data, '__notifications_orders_emails'));
             $__emails = array_filter(array_unique($__emails));
             $emails = array();
             foreach ($__emails as $__email) {
                 if (\Mailer\Abstracts\Sender::isEmailAddress($__email)) {
                     $emails[] = $__email;
                 }
             }
             $this->app->set('REQUEST.notifications.orders.emails', $emails);
             // do the save and redirect to $this->settings_route
             return $this->save();
             break;
     }
     $flash = \Dsc\Flash::instance();
     $this->app->set('flash', $flash);
     $settings = \Shop\Models\Settings::fetch();
     $flash->store($settings->cast());
     $this->app->set('meta.title', 'Notifications | Shop');
     echo $this->theme->render('Shop/Admin/Views::settings/notifications.php');
 }
コード例 #2
0
ファイル: Cookie.php プロジェクト: dioscouri/f3-lib
 /**
  * Get the value of a cookie.
  *
  * @param  string  $name
  * @param  mixed   $default
  * @return string
  */
 public static function get($name, $default = null)
 {
     if (isset(static::$jar[$name])) {
         return static::$jar[$name]['value'];
     }
     return \Dsc\ArrayHelper::get($_COOKIE, $name, $default);
 }
コード例 #3
0
ファイル: Module.php プロジェクト: dioscouri/f3-modules
 public function options()
 {
     $data = \Base::instance()->get('REQUEST');
     // get the metadata.type
     if (!($type = \Dsc\ArrayHelper::get($data, 'type'))) {
         return;
     }
     $view = \Dsc\System::instance()->get('theme');
     $view->event = $view->trigger('onDisplayAdminModuleEdit', array('module' => $type, 'item' => $this->getItem(), 'tabs' => array(), 'content' => array()));
     $html = $view->renderLayout('Modules/Admin/Views::modules/options.php');
     $response = $this->getJsonResponse(array('message' => $html));
     return $this->outputJson($response);
 }
コード例 #4
0
ファイル: OrderedGiftCard.php プロジェクト: dioscouri/f3-shop
 /**
  * Target for POST to create new record
  */
 public function add()
 {
     $f3 = \Base::instance();
     $flash = \Dsc\Flash::instance();
     $data = \Base::instance()->get('REQUEST');
     //\Dsc\System::addMessage( \Dsc\Debug::dump($data) );
     if (!$this->canCreate($data)) {
         throw new \Exception('Not allowed to add record');
     }
     $__customers = explode(",", \Dsc\ArrayHelper::get($data, '__customers'));
     $__emails = explode(",", \Dsc\ArrayHelper::get($data, '__emails'));
     $emails = array_filter(array_unique(array_merge(array(), $__customers, $__emails)));
     if (!empty($emails)) {
         try {
             $this->getModel()->issueToEmails($data, $emails);
             switch ($data['submitType']) {
                 case "save_new":
                     $route = $this->create_item_route;
                     break;
                 case "save_close":
                 default:
                     $route = $this->list_route;
                     break;
             }
             $this->setRedirect($route);
         } catch (\Exception $e) {
             \Dsc\System::instance()->addMessage('Save failed with the following errors:', 'error');
             \Dsc\System::instance()->addMessage($e->getMessage(), 'error');
             if (\Base::instance()->get('DEBUG')) {
                 \Dsc\System::instance()->addMessage($e->getTraceAsString(), 'error');
             }
             // redirect back to the create form with the fields pre-populated
             \Dsc\System::instance()->setUserState('use_flash.' . $this->create_item_route, true);
             $flash->store($data);
             $this->setRedirect($this->create_item_route);
         }
     } else {
         // create just a single gift card
         $this->doAdd($data);
     }
     \Dsc\System::addMessage('Gift cards issued');
     if ($route = $this->getRedirect()) {
         \Base::instance()->reroute($route);
     }
     return;
 }
コード例 #5
0
ファイル: ModifyTo.php プロジェクト: dioscouri/f3-massupdate
 /**
  * This method returns update clause which will be later on passed to collection
  * 
  * @param 	$data		Data from request
  * @param	$params		Arrays with possible additional params (for different modes of updater
  * 
  * @return	Based on mode of updater, either update clause or updated document
  */
 public function getUpdateClause($data, $params = array())
 {
     // check required parameters
     if (!$this->checkParams($params)) {
         return null;
     }
     $data = $this->inputFilter()->clean($data, "string");
     switch ($this->attribute->getUpdaterMode()) {
         case 0:
             throw new \Exception("Unsupported mode for this operation in Mass Update");
             break;
         case 1:
             $doc = $params['document'];
             $name_with_idx = $this->getNameWithIdx();
             $dataset = $params['dataset'];
             $attr_collection = $this->attribute->getAttributeCollection();
             $name_type = $name_with_idx . '_type';
             $name_op = $name_with_idx . '_operation';
             // cant find type => skip this
             if (empty($dataset[$name_type]) || empty($dataset[$name_op])) {
                 return null;
             }
             $act_data = \Dsc\ArrayHelper::get($doc, $attr_collection);
             $res = '';
             $type = $dataset[$name_type];
             $op = $dataset[$name_op];
             switch ($op) {
                 case '+':
                     $res = $this->handleAdding($type, $act_data, $data);
                     break;
                 case '-':
                     $res = $this->handleRemoving($type, $act_data, $data);
                     break;
                 default:
                     $res = $act_data;
                     break;
             }
             \Dsc\ObjectHelper::set($doc, $attr_collection, $res);
             return $doc;
         default:
             throw new \Exception("Unknown type of operation in Mass Update");
     }
 }
コード例 #6
0
ファイル: Prefabs.php プロジェクト: dioscouri/f3-lib
 /**
  *	Retrieve value of field
  *	@return scalar|FALSE
  *	@param $key string
  **/
 function get($key, $default = null)
 {
     return \Dsc\ArrayHelper::get($this->document, $key, $default);
 }
コード例 #7
0
ファイル: profiles.php プロジェクト: dioscouri/f3-users
    echo $network;
    ?>
">
                        <i class="fa fa-times"></i>
                    </a>                                        
                </div>
                <div class="panel-body">
                    <p><img src="<?php 
    echo $profile_img;
    ?>
" alt="<?php 
    echo $name;
    ?>
" class="img-responsive" /></p>
                    <a href="<?php 
    echo \Dsc\ArrayHelper::get($profile, 'profile.profileURL');
    ?>
" target="_blank"><?php 
    echo $name;
    ?>
</a>
                </div>
            </div>
    
        </div>
                    
        <?php 
    $n++;
    if ($n % 4 == 0 || $n == $count) {
        ?>
</div><?php 
コード例 #8
0
ファイル: product_reviews.php プロジェクト: dioscouri/f3-shop
     ?>
                             <p class="detail-line">
                                 SKU: <?php 
     echo \Dsc\ArrayHelper::get($item, 'order_item.sku');
     ?>
                             </p>
                             <?php 
 }
 ?>
                             
                             <?php 
 if (\Dsc\ArrayHelper::get($item, 'order_item.order_created.time')) {
     ?>
                             <p class="detail-line">
                                 <strong>Ordered:</strong> <?php 
     echo date('M j, Y', \Dsc\ArrayHelper::get($item, 'order_item.order_created.time'));
     ?>
                             </p>
                             <?php 
 }
 ?>
                         </div>
                     </div>                
                 </div>
             </div>
         </div>
     
         <div class="col-xs-12 col-sm-7 col-md-7">
             <?php 
 if ($review = \Shop\Models\ProductReviews::hasUserReviewed($this->auth->getIdentity(), $item)) {
     ?>
コード例 #9
0
ファイル: read.php プロジェクト: dioscouri/f3-shop
    ?>
                    <h5>Automatic Coupons</h5>
                    <ul class="list-group">
                    <?php 
    foreach ($autoCoupons as $coupon) {
        ?>
                        <li class="list-group-item">
                            <div class="row">
                                <div class="col-md-2">
                                    <?php 
        echo \Dsc\ArrayHelper::get($coupon, 'code');
        ?>
                                </div>
                                <div class="col-md-10">
                                    <span class="price"><?php 
        echo \Shop\Models\Currency::format($price = \Dsc\ArrayHelper::get($coupon, 'amount'));
        ?>
</span>
                                </div>
                            </div>
                        </li>
                    <?php 
    }
    ?>
                    </ul>
                    <?php 
}
?>
                    
                </div>
                <!-- /.col-md-10 -->
コード例 #10
0
ファイル: review_products.php プロジェクト: dioscouri/f3-shop
        echo \Dsc\ArrayHelper::get($item, 'attribute_title');
        ?>
</small>
                </div>
                <?php 
    }
    ?>
            </h4>
        </td>
        <td style="vertical-align: middle;">
            <span style="border: thin solid #ccc; padding: 10px;">
            <a class="btn btn-link" href="<?php 
    echo $SCHEME . '://' . $HOST . $BASE;
    ?>
/shop/account/product-reviews?filter[keyword]=<?php 
    echo \Dsc\ArrayHelper::get($item, 'product.title');
    ?>
">Write a review</a>
            </span>
        </td>
    </tr>        
    <?php 
}
?>
</table>

<hr/>

<p>Check out <a class="btn btn-link" href="<?php 
echo $SCHEME . '://' . $HOST . $BASE;
?>
コード例 #11
0
ファイル: review_products.php プロジェクト: dioscouri/f3-shop
Thank you for your recent order! 
 
Please take a moment to let us know what you think of your purchases. 
 
<?php 
foreach ($products as $item) {
    ?>
--- 

<?php 
    echo \Dsc\ArrayHelper::get($item, 'product.title');
    ?>
 
<?php 
    if (\Dsc\ArrayHelper::get($item, 'attribute_title')) {
        echo \Dsc\ArrayHelper::get($item, 'attribute_title');
    }
    ?>
 
<?php 
}
?>
 
 
To review any of your recent and past purchases, open this URL in your browser: 
<?php 
echo $SCHEME . '://' . $HOST . $BASE;
?>
/shop/account/product-reviews 
 
Thanks!
コード例 #12
0
ファイル: Customers.php プロジェクト: dioscouri/f3-shop
 /**
  * Check that customer has been rewarded all the appropriate campaigns
  */
 public function checkCampaigns()
 {
     // get all the published campaigns and see if the customer satisfies any of them.
     $campaigns = (new \Shop\Models\Campaigns())->setState('filter.published_today', true)->setState('filter.publication_status', 'published')->getList();
     //echo "Published campaigns: " . count($campaigns) . "<br/>";
     $indexed_campaigns = array();
     foreach ($campaigns as $campaign) {
         try {
             $campaign->__user_qualifies = $campaign->customerQualifies($this);
             $indexed_campaigns[(string) $campaign->id] = $campaign;
         } catch (\Exception $e) {
             continue;
         }
     }
     $matches = array();
     // if so, grant the customer the benefits, but only if the customer doesn't satisfy the rules of any descendants
     //echo "Customer qualifies for this many campaigns: " . count($indexed_campaigns) . "<br/>";
     //echo "and they are: <br/>";
     foreach ($indexed_campaigns as $key => $indexed_campaign) {
         $next_match = $indexed_campaign;
         // Does the campaign have descendants?
         if ($indexed_campaign->__descendants = $indexed_campaign->ancestorsGetDescendants()) {
             foreach ($indexed_campaign->__descendants as $descendant) {
                 if (isset($indexed_campaigns[(string) $descendant->id])) {
                     $next_match = $descendant;
                 }
             }
         }
         $indexed_campaign->__replace_with = null;
         if ($next_match->id != $indexed_campaign->id) {
             $indexed_campaign->__replace_with = $next_match;
         }
         if (!array_key_exists((string) $next_match->id, $matches)) {
             $matches[(string) $next_match->id] = $next_match;
         }
         //echo $indexed_campaign->title . " (which has " . count($indexed_campaign->__descendants) . " descendants) <br/>";
     }
     // Check all of the customer's current campaigns,
     // and if they have expired
     // OR if they are being replaced by a descendant,
     // expire the benefits
     $active_campaign_ids = array();
     if ($active_campaigns = (array) $this->{'shop.active_campaigns'}) {
         foreach ($active_campaigns as $key => $active_campaign_cast) {
             $active_campaign_id = (string) \Dsc\ArrayHelper::get($active_campaign_cast, 'id');
             $active_campaign_expires_time = \Dsc\ArrayHelper::get($active_campaign_cast, 'expires.time');
             $active_campaign = (new \Shop\Models\Campaigns())->setState('filter.id', $active_campaign_id)->getItem();
             $replacing_with_descendant = false;
             // Does the campaign have descendants?
             if ($active_campaign->__descendants = $active_campaign->ancestorsGetDescendants()) {
                 foreach ($active_campaign->__descendants as $descendant) {
                     if (isset($matches[(string) $descendant->id])) {
                         $replacing_with_descendant = true;
                     }
                 }
             }
             // are we replacing this?  Has it expired?
             if ($active_campaign_expires_time < time() || $replacing_with_descendant) {
                 // echo "Removing customer from: " . $active_campaign->title . "<br/>";
                 $active_campaign->expireCustomerRewards($this);
                 unset($active_campaigns[$key]);
             } else {
                 // Only track this if it really is active
                 $active_campaign_ids[] = $active_campaign_id;
             }
         }
     }
     //echo "Customer's active campaigns: <br/>";
     //echo \Dsc\Debug::dump($active_campaigns);
     //echo "Customer should only be in these campaigns: <br/>";
     // Now add the customer to any new campaigns they qualify for
     foreach ($matches as $match) {
         //echo $match->title . "<br/>";
         if (!in_array((string) $match->id, $active_campaign_ids)) {
             $match->rewardCustomer($this);
             //echo "so Adding customer to: " . $match->title . "<br/>";
             $active_campaigns[] = array('id' => (string) $match->id, 'title' => (string) $match->title, 'activated' => \Dsc\Mongo\Metastamp::getDate('now'), 'expires' => \Dsc\Mongo\Metastamp::getDate($match->expires()));
         }
     }
     // Track current campaigns in the user object, shop.active_campaigns
     $this->{'shop.active_campaigns'} = array_values($active_campaigns);
     return $this->save();
 }
コード例 #13
0
ファイル: Encryptable.php プロジェクト: dioscouri/f3-lib
 /**
  * This method encrypts fields in provided array
  *
  * @param $arr Array
  *            field to be encrypted
  *            
  * @return Array with encrypted fields
  */
 private function encryptFieldsModel($arr)
 {
     if (!empty($this->__config['encrypted_fields'])) {
         $encrypted_fields = $this->__config['encrypted_fields'];
         if (is_array($encrypted_fields) === false) {
             $encrypted_fields = array($encrypted_fields);
         }
         foreach ($encrypted_fields as $field) {
             $field_text = \Dsc\ArrayHelper::get($arr, $field);
             if (!is_null($field_text)) {
                 \Dsc\ArrayHelper::set($arr, $field, $this->encryptTextBase64($field_text));
             }
         }
     }
     return $arr;
 }
コード例 #14
0
ファイル: Products.php プロジェクト: dioscouri/f3-shop
 /**
  * 
  * @param unknown $title
  * @return Ambigous <boolean, unknown>
  */
 public function findAttributeByTitle($title)
 {
     $return = false;
     foreach ($this->attributes as $attribute) {
         $attribute_title = \Dsc\ArrayHelper::get($attribute, 'title');
         if (strtolower($title) == strtolower($attribute_title)) {
             $return = $attribute;
             break;
         }
     }
     return $return;
 }
コード例 #15
0
ファイル: index.php プロジェクト: dioscouri/f3-shop
                if (\Dsc\ArrayHelper::get($cartitem, 'attribute_title')) {
                    ?>
                                    <div><small><?php 
                    echo \Dsc\ArrayHelper::get($cartitem, 'attribute_title');
                    ?>
</small></div>
                                    <?php 
                }
                ?>
                                            
                                    <?php 
                if (\Dsc\ArrayHelper::get($cartitem, 'sku')) {
                    ?>
                                    <div>
                                        <small><label>SKU:</label> <?php 
                    echo \Dsc\ArrayHelper::get($cartitem, 'sku');
                    ?>
</small>
                                    </div>
                                    <?php 
                }
                ?>
                                    
                                </li>
                            <?php 
            }
            ?>
                            </ul>
                            <?php 
        }
        ?>
コード例 #16
0
ファイル: list.php プロジェクト: dioscouri/f3-shop
                                        <?php 
            }
            ?>
                        
                                    </div>
                                    <div class="details">
                    
                                    </div>
                                    <div>
                                        <span class="quantity"><?php 
            echo \Dsc\ArrayHelper::get($wishlistitem, 'quantity');
            ?>
</span>
                                        x
                                        <span class="price"><?php 
            echo \Shop\Models\Currency::format(\Dsc\ArrayHelper::get($wishlistitem, 'price'));
            ?>
</span> 
                                    </div>                                
                                </div>
                            </div>        
                            <?php 
        }
        ?>
                        </div>
                        <div class="col-md-2">
                            
                        </div>
                        <div class="col-md-3">
                            <?php 
        echo date('Y-m-d g:i a', $item->{'metadata.last_modified.time'});
コード例 #17
0
ファイル: Coupons.php プロジェクト: dioscouri/f3-shop
 /**
  * Determines if this coupon is valid for a cart
  * 
  * @param \Shop\Models\Carts $cart
  * @throws \Exception
  */
 public function cartValid(\Shop\Models\Carts $cart)
 {
     // Set $this->__is_validated = true if YES, cart can use this coupon
     // throw an Exception if NO, cart cannot use this coupon
     /**
      * is the coupon published?
      */
     if (!$this->published()) {
         throw new \Exception('This coupon is expired.');
     }
     /**
      * Only 1 user-submitted coupon per cart,
      * and if the auto-coupon is exclusive, it can't be added with others
      */
     // If this is a user-submitted coupon && there are other user-submitted coupons in the cart, fail
     if (empty($this->usage_automatic) && $cart->userCoupons() && $cart->userCoupons()[0]['code'] != $this->code) {
         throw new \Exception('Only one coupon allowed per cart');
     }
     // if this is an automatic coupon && usage_with_others == 0 && there are other automatic coupons in the cart
     if ($this->usage_automatic && empty($this->usage_with_others) && $cart->autoCoupons()) {
         throw new \Exception('This coupon cannot be combined with others');
     }
     // TODO take min_subtotal_amount_currency into account once we have currencies sorted
     if (!empty($this->min_subtotal_amount) && $cart->subtotal() < $this->min_subtotal_amount) {
         throw new \Exception('Cart has not met the minimum required subtotal');
     }
     // TODO take min_order_amount_currency into account once we have currencies sorted
     $total = $cart->subtotal() - $cart->giftCardTotal() - $cart->discountTotal() - $cart->creditTotal();
     // Add back the value of this coupon in case it is already applied
     foreach ($cart->allCoupons() as $coupon) {
         if ((string) $coupon['_id'] == (string) $this->id) {
             $total = $total + $coupon['amount'];
             break;
         }
     }
     if (!empty($this->min_order_amount) && $total < $this->min_order_amount) {
         throw new \Exception('Cart has not met the minimum required amount');
     }
     /**
      * check that at least one of the $this->required_products is in the cart
      */
     if (!empty($this->required_products)) {
         // get the IDs of all products in this cart
         $product_ids = array();
         foreach ($cart->items as $cartitem) {
             $product_ids[] = (string) \Dsc\ArrayHelper::get($cartitem, 'product_id');
         }
         $intersection = array_intersect($this->required_products, $product_ids);
         if (empty($intersection)) {
             throw new \Exception('Coupon does not apply to any products in your cart.');
         }
     }
     /**
      * check that at least one of the $this->required_coupons is in the cart
      */
     if (!empty($this->required_coupons)) {
         // get the IDs of all coupons in this cart
         $coupon_ids = array();
         foreach ($cart->userCoupons() as $coupon) {
             $coupon_ids[] = (string) $coupon['_id'];
         }
         foreach ($cart->autoCoupons() as $coupon) {
             $coupon_ids[] = (string) $coupon['_id'];
         }
         $intersection = array_intersect($this->required_coupons, $coupon_ids);
         if (empty($intersection)) {
             throw new \Exception('Cart does not have any of the required coupons');
         }
     }
     /**
      * check that at least one of the products from $this->required_collections is in the cart
      */
     if (!empty($this->required_collections)) {
         // get the IDs of all products in this cart
         $product_ids = array();
         foreach ($cart->items as $cartitem) {
             $product_ids[] = (string) \Dsc\ArrayHelper::get($cartitem, 'product_id');
         }
         $found = false;
         foreach ($this->required_collections as $collection_id) {
             $collection_product_ids = \Shop\Models\Collections::productIds($collection_id);
             $intersection = array_intersect($collection_product_ids, $product_ids);
             if (!empty($intersection)) {
                 $found = true;
                 break;
                 // if its found, break the foreach loop
             }
         }
         if (!$found) {
             throw new \Exception('Coupon does not apply to any products in your cart.');
         }
     }
     /**
      * evaluate shopper groups against $this->groups
      */
     if (!empty($this->groups)) {
         $groups = array();
         $user = (new \Users\Models\Users())->setState('filter.id', $cart->user_id)->getItem();
         if (empty($cart->user_id) || empty($user->id)) {
             // Get the default group
             $group_id = \Shop\Models\Settings::fetch()->{'users.default_group'};
             if (!empty($group_id)) {
                 $groups[] = (new \Users\Models\Groups())->setState('filter.id', (string) $group_id)->getItem();
             }
         } elseif (!empty($user->id)) {
             $groups = $user->groups();
         }
         $group_ids = array();
         foreach ($groups as $group) {
             $group_ids[] = (string) $group->id;
         }
         switch ($this->groups_method) {
             case "none":
                 $intersection = array_intersect($this->groups, $group_ids);
                 if (!empty($intersection)) {
                     throw new \Exception('Your order does not qualify for this discount.');
                 }
                 break;
             case "all":
                 // $missing_groups == the ones from $this->groups that are NOT in $group_ids
                 $missing_groups = array_diff($this->groups, $group_ids);
                 if (!empty($missing_groups)) {
                     throw new \Exception('Your order does not qualify for this discount.');
                 }
                 break;
             case "one":
             default:
                 $intersection = array_intersect($this->groups, $group_ids);
                 if (empty($intersection)) {
                     throw new \Exception('Your order does not qualify for this discount.');
                 }
                 break;
         }
     }
     /**
      * using geo_address_type (shipping/billing) from the cart, check that it is in geo_countries | geo_regions (if either is set)
      */
     if (!empty($this->geo_countries) || !empty($this->geo_regions)) {
         // ok, so which of the addresses should we evaluate?
         switch ($this->geo_address_type) {
             case "billing":
                 $region = $cart->billingRegion();
                 $country = $cart->billingCountry();
                 break;
             case "shipping":
             default:
                 $region = $cart->shippingRegion();
                 $country = $cart->shippingCountry();
                 break;
         }
         if (is_null($region) && !empty($this->geo_regions) || is_null($country) && !empty($this->geo_countries)) {
             throw new \Exception('Customer cannot use this coupon until we know your address');
         }
         if (!empty($this->geo_countries)) {
             // eval the country
             if (!in_array($country, $this->geo_countries)) {
                 throw new \Exception('Shipping address is invalid');
             }
         }
         if (!empty($this->geo_regions)) {
             // eval the region
             if (!in_array($region, $this->geo_regions)) {
                 throw new \Exception('Shipping address is invalid');
             }
         }
     }
     /**
      * Check the usage of the coupon
      */
     if (strlen($this->usage_max)) {
         // usage_max = number of times TOTAL that the coupon may be used
         // count the orders with coupon.code
         $total_count = (new \Shop\Models\Orders())->collection()->count(array('coupons.code' => $this->code));
         if ((int) $this->usage_max <= (int) $total_count) {
             throw new \Exception('Coupon cannot be used any more');
         }
     }
     if (strlen($this->usage_max_per_customer)) {
         // usage_max_per_customer = number of times this customer may use this coupon
         // count the orders with coupon.code for user.id
         $user_count = (new \Shop\Models\Orders())->collection()->count(array('coupons.code' => $this->code, 'user_id' => $cart->user_id));
         if ((int) $this->usage_max_per_customer <= (int) $user_count) {
             throw new \Exception('You cannot use this coupon any more');
         }
     }
     /**
      * Check, if this isn't generated code
      */
     if (!empty($this->generated_code)) {
         $key = new \MongoRegex('/' . $this->generated_code . '/i');
         $result = \Shop\Models\Coupons::collection()->aggregate(array('$match' => array('_id' => new \MongoId((string) $this->id))), array('$unwind' => '$codes.list'), array('$match' => array("codes.list.code" => $key)), array('$group' => array('_id' => '$title', 'used_code' => array('$sum' => '$codes.list.used'))));
         if (count($result['result'])) {
             if ($result['result'][0]['used_code']) {
                 throw new \Exception('You cannot use this coupon any more');
             }
         } else {
             throw new \Exception('Coupon "' . $this->generated_code . '" is no longer available.');
         }
     }
     /**
      * if we made it this far, the cart is valid for this coupon
      */
     $this->__is_validated = true;
     return $this;
 }
コード例 #18
0
ファイル: social.php プロジェクト: dioscouri/f3-users
<?php

foreach ((array) $flash->old('social') as $network => $profile) {
    $profile_img = \Dsc\ArrayHelper::get($profile, 'profile.photoURL');
    $name = \Dsc\ArrayHelper::get($profile, 'profile.displayName');
    if (empty($profile_img)) {
        $profile_img = './minify/Users/Assets/images/empty_profile.png';
    }
    ?>
<div class="panel panel-default">
	<div class="panel-body">
		<div class="row">
			<div class="col-xs-12 col-ms-12 col-md-3">
				<legend><?php 
    echo ucwords($network);
    ?>
</legend>
                    <img src="<?php 
    echo $profile_img;
    ?>
" alt="<?php 
    echo $name;
    ?>
" class="img-responsive" />
			</div>
			<div class="col-xs-12 col-ms-12 col-md-9">
				<a href="<?php 
    echo $profile['profile']['profileURL'];
    ?>
" target="_blank" title="<?php 
    echo $name . ' on ' . ucwords($network);
コード例 #19
0
ファイル: PepperJam.php プロジェクト: dioscouri/f3-shop
 /**
  * \T (tab) delimited feed of products
  * 
  * http://www.pepperjamnetwork.com/doc/product_feed_advanced.html
  * 
  */
 public function productsTxt()
 {
     $settings = \Shop\Models\Settings::fetch();
     if (!$settings->{'feeds.pepperjam_products.enabled'}) {
         return;
     }
     $this->app->set('CACHE', true);
     $cache = \Cache::instance();
     $cache_period = 3600 * 24;
     if ($cache->exists('pepperjam.products_text', $string)) {
         header('Content-Type: text/plain; charset=utf-8');
         echo $string;
         exit;
     }
     $base = \Dsc\Url::base();
     $model = (new \Shop\Models\Products())->setState('filter.published_today', true)->setState('filter.inventory_status', 'in_stock')->setState('filter.publication_status', 'published');
     $conditions = $model->conditions();
     $conditions['product_type'] = array('$nin' => array('giftcard', 'giftcards'));
     $cursor = \Shop\Models\Products::collection()->find($conditions)->sort(array('title' => 1));
     //->limit(10);
     /**
      * name	sku	buy_url	image_url	description_short	description_long	price	manufacturer
      */
     $column_headers = array('name', 'sku', 'buy_url', 'image_url', 'description_short', 'description_long', 'price', 'manufacturer');
     $string = implode("\t", $column_headers) . "\r\n";
     foreach ($cursor as $product_doc) {
         $product = new \Shop\Models\Products($product_doc);
         foreach ($product->variantsInStock() as $variant) {
             $valid = true;
             $price = $product->price($variant['id']);
             // Skip products where price == 0.00
             if (empty($price)) {
                 continue;
             }
             $pieces = array('name' => null, 'sku' => null, 'buy_url' => null, 'image_url' => null, 'description_short' => null, 'description_long' => null, 'price' => null, 'manufacturer' => null);
             $pieces['name'] = $product->title;
             $sku = $variant['sku'] ? $variant['sku'] : $product->{'tracking.sku'};
             if (!$sku) {
                 $sku = $variant['id'];
             }
             $pieces['sku'] = $sku;
             $pieces['buy_url'] = $base . 'shop/product/' . $product->slug . '?variant_id=' . $variant['id'];
             // image_link
             if ($image = $variant['image'] ? $variant['image'] : $product->{'featured_image.slug'}) {
                 $pieces['image_url'] = $base . 'asset/' . $image;
             }
             $pieces['description_short'] = $product->title . ' ';
             if ($attribute_title = \Dsc\ArrayHelper::get($variant, 'attribute_title')) {
                 $pieces['description_short'] .= $attribute_title;
             }
             $pieces['description_short'] = trim($pieces['description_short']);
             $pieces['description_long'] = strip_tags($product->getAbstract());
             $pieces['price'] = $price;
             if ($brand = $settings->{'feeds.pepperjam_products.brand'}) {
                 $pieces['manufacturer'] = $brand;
             }
             global $product;
             //walk peices logging empty values and omiting them
             array_walk($pieces, function (&$value, $key) {
                 global $product;
                 if (empty($value)) {
                     \Dsc\Mongo\Collections\Logs::add($product->title . ' | ID: ' . $product->id . ' is missing ' . $key, 'WARNING', 'PepperJam');
                     $valid = false;
                 }
             });
             if ($valid) {
                 $string .= implode("\t", $pieces) . "\r\n";
             }
         }
     }
     $cache->set('pepperjam.products_text', $string, $cache_period);
     header('Content-Type: text/plain; charset=utf-8');
     echo $string;
     exit;
 }
コード例 #20
0
	<?php 
    }
} else {
    ?>
    <div class="shipping-methods">
    <?php 
    foreach ($cart->shippingMethods() as $method_array) {
        $method = new \Shop\Models\ShippingMethods($method_array);
        ?>
		<div class="form-field radio">
			<label class="control-label">
				<input data-required="true" type="radio" name="checkout[shipping_method]" value="<?php 
        echo $method->{'id'};
        ?>
" <?php 
        if (\Dsc\ArrayHelper::get($cart, 'checkout.shipping_method') == $method->{'id'}) {
            echo 'checked';
        }
        ?>
 />
				<?php 
        echo $method->{'name'};
        ?>
 &mdash; <?php 
        if (empty($method->total())) {
            echo "FREE";
        } else {
            echo \Shop\Models\Currency::format($method->total());
        }
        ?>
			</label>
コード例 #21
0
ファイル: tracking_gtm.php プロジェクト: dioscouri/f3-shop
    {
        <?php 
    $title = \Dsc\ArrayHelper::get($item, 'product.title');
    if (\Dsc\ArrayHelper::get($item, 'attribute_title')) {
        $title .= ' - ' . \Dsc\ArrayHelper::get($item, 'attribute_title');
    }
    ?>
        
        'sku': '<?php 
    echo \Dsc\ArrayHelper::get($item, 'sku');
    ?>
',
        'name': '<?php 
    echo $title;
    ?>
',
        'price': <?php 
    echo (double) \Dsc\ArrayHelper::get($item, 'price');
    ?>
,
        'quantity': <?php 
    echo (int) \Dsc\ArrayHelper::get($item, 'quantity');
    ?>
    }
    <?php 
    $n++;
}
?>
    ]
});
</script>
コード例 #22
0
ファイル: edit.php プロジェクト: dioscouri/f3-shop
echo date('Y-m-d H:i:s', $item->{'metadata.created.time'});
?>
                                    </div>
                                    <div class="col-md-10">
                                        Created
                                    </div>
                                </div>
                            </li>                        
                            <?php 
foreach ($item->history as $history) {
    ?>
                                <li class="list-group-item">
                                    <div class="row">
                                        <div class="col-md-2">
                                            <?php 
    echo \Dsc\ArrayHelper::get($history, 'created.local');
    ?>
                                        </div>
                                        <div class="col-md-10">
                                            <?php 
    $dump = $history;
    unset($dump['created']);
    ?>
                                            <?php 
    echo \Dsc\Debug::dump($dump);
    ?>
                                        </div>
                                    </div>
                                </li>
                            <?php 
}
コード例 #23
0
ファイル: Wishlists.php プロジェクト: dioscouri/f3-shop
 /**
  * Load the product for the specified wishlist item
  * 
  * @param unknown $wishlistitem
  * @return \Shop\Models\Products
  */
 public static function product($wishlistitem)
 {
     $variant_id = \Dsc\ArrayHelper::get($wishlistitem, 'variant_id');
     try {
         $return = (new \Shop\Models\Variants())->getById($variant_id);
     } catch (\Exception $e) {
         $return = new \Shop\Models\Products();
     }
     return $return;
 }
コード例 #24
0
ファイル: read.php プロジェクト: dioscouri/f3-shop
?>
                <div class="list-group">
                <?php 
foreach ((array) $item->{'shop.active_campaigns'} as $active_campaign) {
    ?>
                    <div class="list-group-item">
                        <?php 
    echo \Dsc\ArrayHelper::get($active_campaign, 'title');
    ?>
 
                        as of <span class="label label-default"><?php 
    echo date('Y-m-d', \Dsc\ArrayHelper::get($active_campaign, 'activated.time'));
    ?>
</span>
                        expiring on <span class="label label-default"><?php 
    echo date('Y-m-d', \Dsc\ArrayHelper::get($active_campaign, 'expires.time'));
    ?>
</span>  
                    </div>    
                <?php 
}
?>
                </div>
            </div>
        </div>
    
        <?php 
/* ?>
        <div class="panel panel-default">
            <div class="panel-heading">[List of Customer Orders?]</div>
            <div class="panel-body">
コード例 #25
0
ファイル: Theme.php プロジェクト: dioscouri/f3-lib
 /**
  * Finds the path to the requested view, accounting for overrides
  *
  * @param unknown $view            
  * @return Ambigous <boolean, string>
  */
 public function findViewFile($view)
 {
     static $paths;
     if (empty($paths)) {
         $paths = array();
     }
     $view = str_replace("\\", "/", $view);
     $pieces = \Dsc\String::split(str_replace(array("::", ":"), "|", $view));
     if (isset($paths[$view])) {
         return $paths[$view];
     }
     $paths[$view] = false;
     // 1st. Check if the requested $view has *.{lang}.php format
     $lang = $this->app->get('lang');
     $period_pieces = explode(".", $view);
     // if not, and there is a set LANGUAGE, try to find that view
     if (count($period_pieces) == 2 && !empty($lang)) {
         $lang_view = $period_pieces[0] . "." . $lang . "." . $period_pieces[1];
         if ($lang_view_found = static::findViewFile($lang_view)) {
             return $lang_view_found;
         }
     }
     // otherwise, continue doing the *.php format
     // Overrides!
     //If we are overriding the admin, lets look in an admin  folder.
     $currentTheme = $this->getCurrentTheme();
     if ($currentTheme === 'AdminTheme') {
         if ($adminPath = $this->app->get('admin_override')) {
             $dir = $this->app->get('PATH_ROOT') . $adminPath;
         } else {
             $dir = $this->app->get('PATH_ROOT') . 'apps/Admin/Overrides/';
         }
     } else {
         //else lets look inside whatever theme we are in right now.
         // an overrides folder exists in this theme, let's check for the presence of an override for the requested view file
         $dir = \Dsc\Filesystem\Path::clean($this->getThemePath($this->getCurrentTheme()) . "Overrides/");
     }
     if ($dir = \Dsc\Filesystem\Path::real($dir)) {
         if (count($pieces) > 1) {
             // we're looking for a specific view (e.g. Blog/Site/View::posts/category.php)
             $view_string = $pieces[0];
             $requested_file = $pieces[1];
             $requested_folder = dirname($pieces[1]) == "." ? null : dirname($pieces[1]);
             $requested_filename = basename($pieces[1]);
         } else {
             // (e.g. posts/category.php) that has been requested, so look for it in the overrides dir
             $view_string = null;
             $requested_file = $pieces[0];
             $requested_folder = dirname($pieces[0]) == "." ? null : dirname($pieces[0]);
             $requested_filename = basename($pieces[0]);
         }
         $path = \Dsc\Filesystem\Path::clean($dir . "/" . $view_string . "/" . $requested_folder . "/");
         if ($path = \Dsc\Filesystem\Path::real($path)) {
             $path_pattern = $path . $requested_filename;
             if (file_exists($path_pattern)) {
                 $paths[$view] = $path_pattern;
                 return $paths[$view];
             }
         }
     }
     if (count($pieces) > 1) {
         // we're looking for a specific view (e.g. Blog/Site/View::posts/category.php)
         // $view is a specific app's view/template.php, so try to find it
         $view_string = $pieces[0];
         $requested_file = $pieces[1];
         $view_dir = $this->getViewPath($view_string);
         $path_pattern = $view_dir . $requested_file;
         if (file_exists($path_pattern)) {
             $paths[$view] = $path_pattern;
         }
     } else {
         $requested_file = $pieces[0];
         // it's a view in the format 'common/pagination.php'
         // try to find it in the registered paths
         foreach (\Dsc\ArrayHelper::get($this->dsc_theme, 'views.paths') as $view_path) {
             $path_pattern = $view_path . $requested_file;
             if (file_exists($path_pattern)) {
                 $paths[$view] = $path_pattern;
                 break;
             }
         }
     }
     return $paths[$view];
 }
コード例 #26
0
ファイル: read.php プロジェクト: dioscouri/f3-shop
                                        <td>
                                            <div class="row">
                                                <div class="col-xs-8"><div class="strong">Gift Card</div></div>
                                                <div class="col-xs-4"><a href="./shop/cart/removeGiftCard/<?php 
            echo $giftcard['code'];
            ?>
" class="btn btn-default custom-button"><i class="glyphicon glyphicon-remove"></i></a></div>
                                            </div>
                                            <small><?php 
            echo $giftcard['code'];
            ?>
</small>
                                        </td>
                                        <td class="col-xs-6">
                                            <div class="price">-<?php 
            echo \Shop\Models\Currency::format(\Dsc\ArrayHelper::get($giftcard, 'amount'));
            ?>
</div>
                                        </td>                            
                                    </tr>
                                <?php 
        }
        ?>
                            <?php 
    }
    ?>

                            </tbody>
                            
                            <tfoot>
                                <td><div class="strong">
コード例 #27
0
ファイル: new_order.php プロジェクト: dioscouri/f3-shop
        echo \Dsc\ArrayHelper::get($item, 'attribute_title');
        ?>
</small>
                </div>
                <?php 
    }
    ?>
                <div>
                    <small>
                    <span class="quantity"><?php 
    echo $quantity = \Dsc\ArrayHelper::get($item, 'quantity');
    ?>
</span>
                    x
                    <span class="price"><?php 
    echo \Shop\Models\Currency::format($price = \Dsc\ArrayHelper::get($item, 'price'));
    ?>
</span>
                    </small> 
                </div>
            </h4>
        </td>
        <td style="vertical-align: top; text-align: right;">
            <h4>
                <?php 
    echo \Shop\Models\Currency::format($quantity * $price);
    ?>
            </h4>
        </td>
    </tr>        
    <?php 
コード例 #28
0
ファイル: Models.php プロジェクト: dioscouri/f3-lib
 /**
  * Retrieve value of field
  *
  * @return scalar FALSE
  * @param $key string            
  *
  */
 function get($key, $default = null)
 {
     if ($this->isPublic($key)) {
         return $this->{$key};
     } else {
         return \Dsc\ArrayHelper::get($this->cast(), $key, $default);
     }
 }
コード例 #29
0
ファイル: ObjectHelper.php プロジェクト: dioscouri/f3-lib
 /**
  * Get an item from an object using dot notation
  *
  * @param  array   $array
  * @param  string  $key
  * @param  mixed   $default
  * @return mixed
  */
 public static function get($object, $key, $default = null)
 {
     $array = \Dsc\ArrayHelper::fromObject($object);
     return \Dsc\ArrayHelper::get($array, $key, $default);
 }
コード例 #30
0
ファイル: Carts.php プロジェクト: dioscouri/f3-shop
 /**
  * Return false if not set in checkout.payment_method
  * Return null if set but not found in array of valid payment methods for this cart
  * Return \Shop\Mopdels\Prefabs\PaymentMethods object if found
  *
  */
 public function paymentMethod()
 {
     // is it not set in checkout?
     if (!$this->{'checkout.payment_method'}) {
         return false;
     }
     // otherwise get its full object from the array of methods
     foreach ($this->paymentMethods() as $method_array) {
         if ($this->{'checkout.payment_method'} == \Dsc\ArrayHelper::get($method_array, 'id')) {
             $method = new \Shop\Models\Prefabs\PaymentMethods($method_array);
             return $method;
         }
     }
     return null;
 }