Beispiel #1
0
 /**
  * queue or release newly-purchased GV's
  */
 function update_credit_account($i)
 {
     global $db, $order, $insert_id;
     // only act on newly-purchased gift certificates
     if (preg_match('/^GIFT/', addslashes($order->products[$i]['model']))) {
         // determine how much GV was purchased
         // check if GV was purchased on Special
         $gv_original_price = zen_products_lookup((int) $order->products[$i]['id'], 'products_price');
         // if prices differ assume Special ang get Special Price
         // Do not use this on GVs Priced by Attribute
         if (MODULE_ORDER_TOTAL_GV_SPECIAL == 'true' && ($gv_original_price != 0 && $gv_original_price != $order->products[$i]['final_price'] && !zen_get_products_price_is_priced_by_attributes((int) $order->products[$i]['id']))) {
             $gv_order_amount = $gv_original_price * $order->products[$i]['qty'];
         } else {
             $gv_order_amount = $order->products[$i]['final_price'] * $order->products[$i]['qty'];
         }
         // if tax is to be calculated on purchased GVs, calculate it
         if ($this->credit_tax == 'true') {
             $gv_order_amount = $gv_order_amount * (100 + $order->products[$i]['tax']) / 100;
         }
         $gv_order_amount = $gv_order_amount * 100 / 100;
         if (MODULE_ORDER_TOTAL_GV_QUEUE == 'false') {
             // GV_QUEUE is false so release amount to account immediately
             $gv_result = $this->user_has_gv_account($_SESSION['customer_id']);
             $customer_gv = false;
             $total_gv_amount = 0;
             if ($gv_result) {
                 $total_gv_amount = $gv_result;
                 $customer_gv = true;
             }
             $total_gv_amount = $total_gv_amount + $gv_order_amount;
             if ($customer_gv) {
                 $db->Execute("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $total_gv_amount . "' where customer_id = '" . (int) $_SESSION['customer_id'] . "'");
             } else {
                 $db->Execute("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . (int) $_SESSION['customer_id'] . "', '" . $total_gv_amount . "')");
             }
         } else {
             // GV_QUEUE is true - so queue the gv for release by store owner
             $db->Execute("insert into " . TABLE_COUPON_GV_QUEUE . " (customer_id, order_id, amount, date_created, ipaddr) values ('" . (int) $_SESSION['customer_id'] . "', '" . (int) $insert_id . "', '" . $gv_order_amount . "', NOW(), '" . $_SERVER['REMOTE_ADDR'] . "')");
         }
     }
 }
 function getProducts()
 {
     $this->cleanup();
     if (count($this->products) < 1) {
         return false;
     }
     $exclude_products_id = 0;
     if (isset($_GET['products_id']) && $_GET['products_id'] > 0) {
         $exclude_products_id = (int) $_GET['products_id'];
     }
     $products = array();
     foreach ($this->products as $products_id => $add_date) {
         if ($products_id != $exclude_products_id) {
             $products[] = array('id' => $products_id, 'add_date' => $add_date, 'name' => zen_get_products_name($products_id), 'display_price' => zen_get_products_display_price($products_id), 'image' => DIR_WS_IMAGES . zen_products_lookup($products_id, 'products_image'), 'url' => zen_href_link(zen_get_info_page($products_id), 'products_id=' . $products_id));
         }
         if (count($products) >= MODULE_VIEWED_PRODUCTS_MAX_DISPLAY_VIEWED) {
             break;
         }
     }
     return $products;
 }
 /** Render the name/description column for a product */
 private static function cart_product_name($product)
 {
     $name = "<div><strong><a href='{$product['linkProductsName']}'>" . $product['productsName'] . "</a></strong></div>";
     $stock_check = $product['flagStockCheck'] != '' ? "<span class='alert bold'>{$product['flagStockCheck']}</span>" : '';
     $model = "<small>" . TABLE_HEADING_MODEL . " #" . zen_products_lookup($product['id'], 'products_model') . $stock_check . "</small>";
     $attributes = '';
     if (isset($product['attributes']) && is_array($product['attributes'])) {
         reset($product['attributes']);
         foreach ($product['attributes'] as $option => $value) {
             $attributes .= "<li>" . $value['products_options_name'] . TEXT_OPTION_DIVIDER . nl2br($value['products_options_values_name']) . "</li>";
         }
         if ($attributes !== '') {
             $attributes = "<ul>{$attributes}</ul>";
         }
     }
     return "<div>{$name} {$model} {$attributes}</div>";
 }
 function getProductInfo($id)
 {
     return array('id' => $id, 'name' => zen_products_lookup($id, 'products_name', $_SESSION['languages_id']), 'image' => zen_products_lookup($id, 'products_image', $_SESSION['languages_id']));
 }