if (META_TAG_INCLUDE_PRICE == '1') {
             if ($review_metatags->fields['product_is_free'] != '1') {
                 $meta_products_price = zen_get_products_actual_price($review_metatags->fields['products_id']);
                 $meta_products_price = SECONDARY_SECTION . $currencies->display_price($meta_products_price, zen_get_tax_rate($review_metatags->fields['products_tax_class_id']));
             } else {
                 $meta_products_price = SECONDARY_SECTION . META_TAG_PRODUCTS_PRICE_IS_FREE_TEXT;
             }
         } else {
             $meta_products_price = '';
         }
         if (zen_not_null($review_metatags->fields['products_model'])) {
             $meta_products_name = $review_metatags->fields['products_name'] . ' [' . $review_metatags->fields['products_model'] . ']';
         } else {
             $meta_products_name = $review_metatags->fields['products_name'];
         }
         $meta_products_name = zen_clean_html($meta_products_name);
         $review_text_metatags = substr(strip_tags(stripslashes($review_metatags->fields['reviews_text'])), 0, 60);
         $reviews_rating_metatags = SUB_TITLE_RATING . ' ' . sprintf(TEXT_OF_5_STARS, $review_metatags->fields['reviews_rating']);
         define('META_TAG_TITLE', str_replace('"', '', $meta_products_name . $meta_products_price . PRIMARY_SECTION . TITLE . TERTIARY_SECTION . NAVBAR_TITLE));
         define('META_TAG_DESCRIPTION', str_replace('"', '', TITLE . PRIMARY_SECTION . NAVBAR_TITLE . SECONDARY_SECTION . $meta_products_name . SECONDARY_SECTION . $review_metatags->fields['customers_name'] . SECONDARY_SECTION . $review_text_metatags . ' ' . SECONDARY_SECTION . $reviews_rating_metatags));
         define('META_TAG_KEYWORDS', str_replace('"', '', KEYWORDS . METATAGS_DIVIDER . $meta_products_name . METATAGS_DIVIDER . $review_metatags->fields['customers_name'] . METATAGS_DIVIDER . $reviews_rating_metatags));
     }
     // EOF
     break;
     // EZ-Pages:
 // EZ-Pages:
 case 'page':
     $ezpage_id = (int) $_GET['id'];
     $chapter_id = (int) $_GET['chapter'];
     if (defined('META_TAG_TITLE_EZPAGE_' . $ezpage_id)) {
         define('META_TAG_TITLE', constant('META_TAG_TITLE_EZPAGE_' . $ezpage_id));
 //$featured_res = $db->Execute($feature_query);
 $pid = $products_res->fields['products_id'];
 $sid = $specials_res->fields['products_id'];
 $attribute_product = $product_attribute_query_result->fields['products_id'];
 if ($fid == $pid) {
     $msg_product = "<div class='tag tag-orange' title=''><div class='text'>HOT</div></div>";
 } else {
     if ($fid == $sid) {
         $msg_product = "<div class='tag tag-orange' title=''><div class='text'>SALE</div></div>";
     } else {
         $msg_product = "<div class='tag tag-blue' title=''><div class='text'>NEW</div></div>";
     }
 }
 //$products_description_hover = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($featured_products->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION); //To Display Product Desc on hover
 //$products_description_hover = ltrim(substr($products_description_hover, 0, 115) . '...'); //Trims and Limits the desc on hover
 $products_description = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($featured_products->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION);
 //To Display Product Desc
 $products_description = ltrim(substr($products_description, 0, 350) . '..');
 //Trims and Limits the desc
 //Productname Trim
 //$products_name_hover = $featured_products->fields['products_name'];
 //$products_name_hover = ltrim(substr($products_name_hover, 0, 50) . '...');
 $products_name = $featured_products->fields['products_name'];
 //$products_name = ltrim(substr($products_name, 0, 30) . '');
 if (!isset($productsInCategory[$featured_products->fields['products_id']])) {
     $productsInCategory[$featured_products->fields['products_id']] = zen_get_generated_category_path_rev($featured_products->fields['master_categories_id']);
 }
 /*Wishlist/Compare Links*/
 if (UN_MODULE_WISHLISTS_ENABLED) {
     $wishlist_link = zen_href_link(UN_FILENAME_WISHLIST, 'products_id=' . $featured_products->fields['products_id'] . '&action=wishlist_add_product');
 } else {
     $list_box_contents[$rows] = array('params' => 'class="productListing-odd"');
 }
 $cur_row = sizeof($list_box_contents) - 1;
 for ($col = 0, $n = sizeof($column_list); $col < $n; $col++) {
     $lc_align = '';
     switch ($column_list[$col]) {
         case 'PRODUCT_LIST_MODEL':
             $lc_align = '';
             $lc_text = $listing->fields['products_model'];
             break;
         case 'PRODUCT_LIST_NAME':
             $lc_align = '';
             if (isset($_GET['manufacturers_id'])) {
                 $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'manufacturers_id=' . $_GET['manufacturers_id'] . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
             } else {
                 $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
             }
             break;
         case 'PRODUCT_LIST_MANUFACTURER':
             $lc_align = '';
             $lc_text = '<a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '">' . $listing->fields['manufacturers_name'] . '</a>';
             break;
         case 'PRODUCT_LIST_PRICE':
             $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
             $lc_align = 'right';
             $lc_text = $lc_price;
             // more info in place of buy now
             $lc_button = '';
             if (zen_has_product_attributes($listing->fields['products_id']) or PRODUCT_LIST_PRICE_BUY_NOW == '0') {
                 $lc_button = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
             } else {
Beispiel #4
0
$zc_col_count_description = 0;
$lc_align = '';
$list_box_contents = array();
//echo $listing_split->sql_query;
//print_r(explode(' ',zen_products_id_in_category($current_category_id)));
if (zen_count_products_in_category($current_category_id) > 0) {
    $listing = $db->Execute($listing_split->sql_query);
    $row = 0;
    while (!$listing->EOF) {
        if ($listing->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
            $list_box_contents[$row]['products_image'] = '';
        } else {
            $list_box_contents[$row]['products_image'] = $listing->fields['products_image'];
        }
        $list_box_contents[$row]['products_name'] = $listing->fields['products_name'];
        $list_box_contents[$row]['products_description'] = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), 100);
        $list_box_contents[$row]['products_price'] = zen_get_products_base_price($listing->fields['products_id']);
        $list_box_contents[$row]['actual_price'] = $currencies->display_price(zen_get_products_actual_price($listing->fields['products_id']), zen_get_tax_rate($product_check->fields['products_tax_class_id']));
        $list_box_contents[$row]['products_status'] = $listing->fields['products_status'];
        if ($listing->fields['product_is_always_free_shipping'] == 0) {
            $list_box_contents[$row]['product_is_always_free_shipping'] = '';
        } else {
            $list_box_contents[$row]['product_is_always_free_shipping'] = '<span class="free_shipping"></span>';
        }
        if ($listing->fields['product_is_free'] == 0) {
            $list_box_contents[$row]['product_is_free'] = '';
        } else {
            $list_box_contents[$row]['product_is_free'] = '<span class="free"></span>';
        }
        $list_box_contents[$row]['products_quantity_order_min'] = $listing->fields['products_quantity_order_min'];
        $list_box_contents[$row]['products_id'] = $listing->fields['products_id'];
Beispiel #5
0
function zen_image($src, $alt = '', $width = '', $height = '', $parameters = '')
{
    global $template_dir;
    // soft clean the alt tag
    $alt = zen_clean_html($alt);
    // use old method on template images
    if (strstr($src, 'includes/templates') or strstr($src, 'includes/languages') or PROPORTIONAL_IMAGES_STATUS == '0') {
        return zen_image_OLD($src, $alt, $width, $height, $parameters);
    }
    //auto replace with defined missing image
    if ($src == DIR_WS_IMAGES and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
        $src = DIR_WS_IMAGES . PRODUCTS_IMAGE_NO_IMAGE;
    }
    if ((empty($src) || $src == DIR_WS_IMAGES) && IMAGE_REQUIRED == 'false') {
        return false;
    }
    // if not in current template switch to template_default
    if (!file_exists($src)) {
        $src = str_replace(DIR_WS_TEMPLATES . $template_dir, DIR_WS_TEMPLATES . 'template_default', $src);
    }
    // hook for handle_image() function such as Image Handler etc
    if (function_exists('handle_image')) {
        $newimg = handle_image($src, $alt, $width, $height, $parameters);
        list($src, $alt, $width, $height, $parameters) = $newimg;
    }
    // Convert width/height to int for proper validation.
    // intval() used to support compatibility with plugins like image-handler
    $width = empty($width) ? $width : intval($width);
    $height = empty($height) ? $height : intval($height);
    // alt is added to the img tag even if it is null to prevent browsers from outputting
    // the image filename as default
    $image = '<img src="' . zen_output_string($src) . '" alt="' . zen_output_string($alt) . '"';
    if (zen_not_null($alt)) {
        $image .= ' title=" ' . zen_output_string($alt) . ' "';
    }
    if (CONFIG_CALCULATE_IMAGE_SIZE == 'true' && (empty($width) || empty($height))) {
        if ($image_size = @getimagesize($src)) {
            if (empty($width) && zen_not_null($height)) {
                $ratio = $height / $image_size[1];
                $width = $image_size[0] * $ratio;
            } elseif (zen_not_null($width) && empty($height)) {
                $ratio = $width / $image_size[0];
                $height = $image_size[1] * $ratio;
            } elseif (empty($width) && empty($height)) {
                $width = $image_size[0];
                $height = $image_size[1];
            }
        } elseif (IMAGE_REQUIRED == 'false') {
            return false;
        }
    }
    if (zen_not_null($width) && zen_not_null($height) and file_exists($src)) {
        //      $image .= ' width="' . zen_output_string($width) . '" height="' . zen_output_string($height) . '"';
        // proportional images
        $image_size = @getimagesize($src);
        // fix division by zero error
        $ratio = $image_size[0] != 0 ? $width / $image_size[0] : 1;
        if ($image_size[1] * $ratio > $height) {
            $ratio = $height / $image_size[1];
            $width = $image_size[0] * $ratio;
        } else {
            $height = $image_size[1] * $ratio;
        }
        // only use proportional image when image is larger than proportional size
        if ($image_size[0] < $width and $image_size[1] < $height) {
            $image .= ' width="' . $image_size[0] . '" height="' . intval($image_size[1]) . '"';
        } else {
            $image .= ' width="' . round($width) . '" height="' . round($height) . '"';
        }
    } else {
        // override on missing image to allow for proportional and required/not required
        if (IMAGE_REQUIRED == 'false') {
            return false;
        } else {
            $image .= ' width="' . intval(SMALL_IMAGE_WIDTH) . '" height="' . intval(SMALL_IMAGE_HEIGHT) . '"';
        }
    }
    // inject rollover class if one is defined. NOTE: This could end up with 2 "class" elements if $parameters contains "class" already.
    if (defined('IMAGE_ROLLOVER_CLASS') && IMAGE_ROLLOVER_CLASS != '') {
        $parameters .= (zen_not_null($parameters) ? ' ' : '') . 'class="rollover"';
    }
    // add $parameters to the tag output
    if (zen_not_null($parameters)) {
        $image .= ' ' . $parameters;
    }
    $image .= ' />';
    return $image;
}
 /**
  * Prepare subtotal and line-item detail content to send to PayPal
  */
 function getLineItemDetails($restrictedCurrency)
 {
     global $order, $currencies, $order_totals, $order_total_modules;
     // if not default currency, do not send subtotals or line-item details
     if (DEFAULT_CURRENCY != $order->info['currency'] || $restrictedCurrency != DEFAULT_CURRENCY) {
         $this->zcLog('getLineItemDetails 1', 'Not using default currency. Thus, no line-item details can be submitted.');
         return array();
     }
     if ($currencies->currencies[$_SESSION['currency']]['value'] != 1 || $currencies->currencies[$order->info['currency']]['value'] != 1) {
         $this->zcLog('getLineItemDetails 2', 'currency val not equal to 1.0000 - cannot proceed without coping with currency conversions. Aborting line-item details.');
         return array();
     }
     $optionsST = array();
     $optionsLI = array();
     $optionsNB = array();
     $numberOfLineItemsProcessed = 0;
     $creditsApplied = 0;
     $surcharges = 0;
     $sumOfLineItems = 0;
     $sumOfLineTax = 0;
     $optionsST['AMT'] = 0;
     $optionsST['ITEMAMT'] = 0;
     $optionsST['TAXAMT'] = 0;
     $optionsST['SHIPPINGAMT'] = 0;
     $optionsST['SHIPDISCAMT'] = 0;
     $optionsST['HANDLINGAMT'] = 0;
     $optionsST['INSURANCEAMT'] = 0;
     $flagSubtotalsUnknownYet = true;
     $subTotalLI = 0;
     $subTotalTax = 0;
     $subTotalShipping = 0;
     $subtotalPRE = array('no data');
     $discountProblemsFlag = FALSE;
     $flag_treat_as_partial = FALSE;
     if (sizeof($order_totals)) {
         // prepare subtotals
         for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
             if ($order_totals[$i]['code'] == '') {
                 continue;
             }
             if (in_array($order_totals[$i]['code'], array('ot_total', 'ot_subtotal', 'ot_tax', 'ot_shipping')) || strstr($order_totals[$i]['code'], 'insurance')) {
                 if ($order_totals[$i]['code'] == 'ot_shipping') {
                     $optionsST['SHIPPINGAMT'] = round($order_totals[$i]['value'], 2);
                 }
                 if ($order_totals[$i]['code'] == 'ot_total') {
                     $optionsST['AMT'] = round($order_totals[$i]['value'], 2);
                 }
                 if ($order_totals[$i]['code'] == 'ot_tax') {
                     $optionsST['TAXAMT'] = round($order_totals[$i]['value'], 2);
                 }
                 if ($order_totals[$i]['code'] == 'ot_subtotal') {
                     $optionsST['ITEMAMT'] = round($order_totals[$i]['value'], 2);
                 }
                 if (strstr($order_totals[$i]['code'], 'insurance')) {
                     $optionsST['INSURANCEAMT'] += round($order_totals[$i]['value'], 2);
                 }
                 //$optionsST['SHIPDISCAMT'] = '';  // Not applicable
             } else {
                 // handle other order totals:
                 global ${$order_totals[$i]['code']};
                 if (substr($order_totals[$i]['text'], 0, 1) == '-' || isset(${$order_totals[$i]['code']}->credit_class) && ${$order_totals[$i]['code']}->credit_class == true) {
                     // handle credits
                     $creditsApplied += round($order_totals[$i]['value'], 2);
                 } else {
                     // treat all other OT's as if they're related to handling fees or other extra charges to be added/included
                     $surcharges += $order_totals[$i]['value'];
                 }
             }
         }
         if ($creditsApplied > 0) {
             $optionsST['ITEMAMT'] -= $creditsApplied;
         }
         if ($surcharges > 0) {
             $optionsST['ITEMAMT'] += $surcharges;
         }
         // Handle tax-included scenario
         if (DISPLAY_PRICE_WITH_TAX == 'true') {
             $optionsST['TAXAMT'] = 0;
         }
         $subtotalPRE = $optionsST;
         // Move shipping tax amount from Tax subtotal into Shipping subtotal for submission to PayPal, since PayPal applies tax to each line-item individually
         $module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_'));
         if (zen_not_null($order->info['shipping_method']) && DISPLAY_PRICE_WITH_TAX != 'true') {
             if ($GLOBALS[$module]->tax_class > 0) {
                 $shipping_tax_basis = !isset($GLOBALS[$module]->tax_basis) ? STORE_SHIPPING_TAX_BASIS : $GLOBALS[$module]->tax_basis;
                 $shippingOnBilling = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']);
                 $shippingOnDelivery = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                 if ($shipping_tax_basis == 'Billing') {
                     $shipping_tax = $shippingOnBilling;
                 } elseif ($shipping_tax_basis == 'Shipping') {
                     $shipping_tax = $shippingOnDelivery;
                 } else {
                     if (STORE_ZONE == $order->billing['zone_id']) {
                         $shipping_tax = $shippingOnBilling;
                     } elseif (STORE_ZONE == $order->delivery['zone_id']) {
                         $shipping_tax = $shippingOnDelivery;
                     } else {
                         $shipping_tax = 0;
                     }
                 }
                 $taxAdjustmentForShipping = zen_round(zen_calculate_tax($order->info['shipping_cost'], $shipping_tax), $currencies->currencies[$_SESSION['currency']]['decimal_places']);
                 $optionsST['SHIPPINGAMT'] += $taxAdjustmentForShipping;
                 $optionsST['TAXAMT'] -= $taxAdjustmentForShipping;
             }
         }
         $flagSubtotalsUnknownYet = $optionsST['SHIPPINGAMT'] + $optionsST['SHIPDISCAMT'] + $optionsST['AMT'] + $optionsST['TAXAMT'] + $optionsST['ITEMAMT'] + $optionsST['INSURANCEAMT'] == 0;
     } else {
         // if we get here, we don't have any order-total information yet because the customer has clicked Express before starting normal checkout flow
         // thus, we must make a note to manually calculate subtotals, rather than relying on the more robust order-total infrastructure
         $flagSubtotalsUnknownYet = TRUE;
     }
     // loop thru all products to prepare details of quantity and price.
     for ($i = 0, $n = sizeof($order->products), $k = 0; $i < $n; $i++, $k++) {
         // PayPal won't accept zero-value line-items, so skip this entry if price is zero
         if ($order->products[$i]['final_price'] == 0) {
             continue;
         }
         $optionsLI["L_NUMBER{$k}"] = $order->products[$i]['model'];
         $optionsLI["L_NAME{$k}"] = $order->products[$i]['name'];
         // Append *** if out-of-stock.
         $optionsLI["L_NAME{$k}"] .= zen_get_products_stock($order->products[$i]['id']) - $order->products[$i]['qty'] < 0 ? STOCK_MARK_PRODUCT_OUT_OF_STOCK : '';
         // if there are attributes, loop thru them and add to description
         if (isset($order->products[$i]['attributes']) && sizeof($order->products[$i]['attributes']) > 0) {
             $optionsLI["L_DESC{$k}"] = '';
             for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) {
                 $optionsLI["L_DESC{$k}"] .= "\n " . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
             }
             // end loop
         }
         // endif attribute-info
         // check for rounding problems with taxes
         $m1 = zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
         $m2 = $order->products[$i]['qty'] * zen_round($order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
         $n1 = $order->products[$i]['qty'] * zen_calculate_tax($order->products[$i]['final_price'], $order->products[$i]['tax']);
         $n2 = zen_calculate_tax($order->products[$i]['qty'] * $order->products[$i]['final_price'], $order->products[$i]['tax']);
         if ($m1 != $m2 || zen_round($n1, $currencies->currencies[$_SESSION['currency']]['decimal_places']) != zen_round($n2, $currencies->currencies[$_SESSION['currency']]['decimal_places'])) {
             $flag_treat_as_partial = true;
         }
         // PayPal can't handle partial-quantity values, so fudge it here
         if ($flag_treat_as_partial || $order->products[$i]['qty'] != (int) $order->products[$i]['qty']) {
             $optionsLI["L_NAME{$k}"] = '(' . $order->products[$i]['qty'] . ' x ) ' . $optionsLI["L_NAME{$k}"];
             $optionsLI["L_AMT{$k}"] = zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']);
             $optionsLI["L_TAXAMT{$k}"] = zen_calculate_tax(zen_round($order->products[$i]['qty'] * $order->products[$i]['final_price'], $currencies->currencies[$_SESSION['currency']]['decimal_places']), $order->products[$i]['tax']);
             $optionsLI["L_QTY{$k}"] = 1;
         } else {
             $optionsLI["L_AMT{$k}"] = $order->products[$i]['final_price'];
             $optionsLI["L_QTY{$k}"] = $order->products[$i]['qty'];
             $optionsLI["L_TAXAMT{$k}"] = zen_calculate_tax(1 * $order->products[$i]['final_price'], $order->products[$i]['tax']);
         }
         // For tax-included pricing, combine tax with price instead of treating separately:
         if (DISPLAY_PRICE_WITH_TAX == 'true') {
             $optionsLI["L_AMT{$k}"] += $optionsLI["L_TAXAMT{$k}"];
             $optionsLI["L_TAXAMT{$k}"] = 0;
         }
         $subTotalLI += $optionsLI["L_QTY{$k}"] * $optionsLI["L_AMT{$k}"];
         $subTotalTax += $optionsLI["L_QTY{$k}"] * $optionsLI["L_TAXAMT{$k}"];
         // add line-item for one-time charges on this product
         if ($order->products[$i]['onetime_charges'] != 0) {
             $k++;
             $optionsLI["L_NAME{$k}"] = MODULES_PAYMENT_PAYPALWPP_LINEITEM_TEXT_ONETIME_CHARGES_PREFIX . substr(htmlentities($order->products[$i]['name'], ENT_QUOTES, 'UTF-8'), 0, 120);
             $optionsLI["L_AMT{$k}"] = $order->products[$i]['onetime_charges'];
             $optionsLI["L_QTY{$k}"] = 1;
             $optionsLI["L_TAXAMT{$k}"] = zen_calculate_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']);
             $subTotalLI += $order->products[$i]['onetime_charges'];
             $subTotalTax += $optionsLI["L_TAXAMT{$k}"];
         }
         $numberOfLineItemsProcessed = $k;
     }
     // end for loopthru all products
     // add line items for any surcharges added by order-total modules
     if ($surcharges > 0) {
         $numberOfLineItemsProcessed++;
         $k = $numberOfLineItemsProcessed;
         $optionsLI["L_NAME{$k}"] = MODULES_PAYMENT_PAYPALWPP_LINEITEM_TEXT_SURCHARGES_SHORT;
         $optionsLI["L_DESC{$k}"] = MODULES_PAYMENT_PAYPALWPP_LINEITEM_TEXT_SURCHARGES_LONG;
         $optionsLI["L_AMT{$k}"] = $surcharges;
         $optionsLI["L_QTY{$k}"] = 1;
         $subTotalLI += $surcharges;
     }
     // add line items for discounts such as gift certificates and coupons
     if ($creditsApplied > 0) {
         $numberOfLineItemsProcessed++;
         $k = $numberOfLineItemsProcessed;
         $optionsLI["L_NAME{$k}"] = MODULES_PAYMENT_PAYPALWPP_LINEITEM_TEXT_DISCOUNTS_SHORT;
         $optionsLI["L_DESC{$k}"] = MODULES_PAYMENT_PAYPALWPP_LINEITEM_TEXT_DISCOUNTS_LONG;
         $optionsLI["L_AMT{$k}"] = -1 * $creditsApplied;
         $optionsLI["L_QTY{$k}"] = 1;
         $subTotalLI -= $creditsApplied;
     }
     // Reformat properly
     for ($k = 0, $n = $numberOfLineItemsProcessed + 1; $k < $n; $k++) {
         // Replace & and = and % with * if found.
         $optionsLI["L_NAME{$k}"] = str_replace(array('&', '=', '%'), '*', $optionsLI["L_NAME{$k}"]);
         if (isset($optionsLI["L_DESC{$k}"])) {
             $optionsLI["L_DESC{$k}"] = str_replace(array('&', '=', '%'), '*', $optionsLI["L_DESC{$k}"]);
         }
         if (isset($optionsLI["L_NUMBER{$k}"])) {
             $optionsLI["L_NUMBER{$k}"] = str_replace(array('&', '=', '%'), '*', $optionsLI["L_NUMBER{$k}"]);
         }
         // Remove HTML markup if found
         $optionsLI["L_NAME{$k}"] = zen_clean_html($optionsLI["L_NAME{$k}"], 'strong');
         if (isset($optionsLI["L_DESC{$k}"])) {
             $optionsLI["L_DESC{$k}"] = zen_clean_html($optionsLI["L_DESC{$k}"], 'strong');
         }
         // reformat properly according to API specs
         $optionsLI["L_NAME{$k}"] = substr($optionsLI["L_NAME{$k}"], 0, 127);
         if (isset($optionsLI["L_NUMBER{$k}"])) {
             $optionsLI["L_NUMBER{$k}"] = substr($optionsLI["L_NUMBER{$k}"], 0, 127);
         }
         if (isset($optionsLI["L_DESC{$k}"]) && $optionsLI["L_DESC{$k}"] == '') {
             unset($optionsLI["L_DESC{$k}"]);
         }
         if (isset($optionsLI["L_DESC{$k}"])) {
             $optionsLI["L_DESC{$k}"] = substr($optionsLI["L_DESC{$k}"], 0, 127);
         }
         if (isset($optionsLI["L_TAXAMT{$k}"]) && ($optionsLI["L_TAXAMT{$k}"] != '' || $optionsLI["L_TAXAMT{$k}"] > 0)) {
             $optionsLI["L_TAXAMT{$k}"] = round($optionsLI["L_TAXAMT{$k}"], 2);
         }
     }
     /**
      * PayPal says their math works like this:
      * a) ITEMAMT = L_AMTn * L_QTYn
      * b) TAXAMT = L_QTYn * L_TAXAMTn
      * c) AMT = ITEMAMT + SHIPPINGAMT + HANDLINGAMT + TAXAMT
      */
     // Sanity Check of line-item subtotals
     for ($j = 0; $j < $k; $j++) {
         $itemAMT = $optionsLI["L_AMT{$j}"];
         $itemQTY = $optionsLI["L_QTY{$j}"];
         $itemTAX = isset($optionsLI["L_TAXAMT{$j}"]) ? $optionsLI["L_TAXAMT{$j}"] : 0;
         $sumOfLineItems += $itemQTY * $itemAMT;
         $sumOfLineTax += $itemQTY * $itemTAX;
     }
     $sumOfLineItems = round($sumOfLineItems, 2);
     $sumOfLineTax = round($sumOfLineTax, 2);
     if ($sumOfLineItems == 0) {
         $sumOfLineTax = 0;
         $optionsLI = array();
         $discountProblemsFlag = TRUE;
         if ($optionsST['SHIPPINGAMT'] == $optionsST['AMT']) {
             $optionsST['SHIPPINGAMT'] = 0;
         }
     }
     // Sanity check -- if tax-included pricing is causing problems, remove the numbers and put them in a comment instead:
     $stDiffTaxOnly = strval($sumOfLineItems - $sumOfLineTax - round($optionsST['AMT'], 2)) + 0;
     if (DISPLAY_PRICE_WITH_TAX == 'true' && $stDiffTaxOnly == 0) {
         $optionsNB['DESC'] = 'Tax included in prices: ' . $sumOfLineTax . ' (' . $optionsST['TAXAMT'] . ') ';
         $optionsST['TAXAMT'] = 0;
         for ($k = 0, $n = $numberOfLineItemsProcessed + 1; $k < $n; $k++) {
             if (isset($optionsLI["L_TAXAMT{$k}"])) {
                 unset($optionsLI["L_TAXAMT{$k}"]);
             }
         }
     }
     // Do sanity check -- if any of the line-item subtotal math doesn't add up properly, skip line-item details,
     // so that the order can go through even though PayPal isn't being flexible to handle Zen Cart's diversity
     if (strval($subTotalTax) - strval($sumOfLineTax) > 0.02) {
         $this->zcLog('getLineItemDetails 3', 'Tax Subtotal does not match sum of taxes for line-items. Tax details are being removed from line-item submission data.' . "\n" . $sumOfLineTax . ' ' . $subTotalTax . print_r(array_merge($optionsST, $optionsLI), true));
         for ($k = 0, $n = $numberOfLineItemsProcessed + 1; $k < $n; $k++) {
             if (isset($optionsLI["L_TAXAMT{$k}"])) {
                 unset($optionsLI["L_TAXAMT{$k}"]);
             }
         }
         $subTotalTax = 0;
         $sumOfLineTax = 0;
     }
     // If coupons exist and there's a calculation problem, then it's likely that taxes are incorrect, so reset L_TAXAMTn values
     if ($creditsApplied > 0 && strval($optionsST['TAXAMT']) != strval($sumOfLineTax)) {
         $pre = $optionsLI;
         for ($k = 0, $n = $numberOfLineItemsProcessed + 1; $k < $n; $k++) {
             if (isset($optionsLI["L_TAXAMT{$k}"])) {
                 unset($optionsLI["L_TAXAMT{$k}"]);
             }
         }
         $this->zcLog('getLineItemDetails 4', 'Coupons/Discounts have affected tax calculations, so tax details are being removed from line-item submission data.' . "\n" . $sumOfLineTax . ' ' . $optionsST['TAXAMT'] . "\n" . print_r(array_merge($optionsST, $pre, $optionsNB), true) . "\nAFTER:" . print_r(array_merge($optionsST, $optionsLI, $optionsNB), TRUE));
         $subTotalTax = 0;
         $sumOfLineTax = 0;
     }
     if (TRUE) {
         // disable line-item tax details, leaving only TAXAMT subtotal as tax indicator
         for ($k = 0, $n = $numberOfLineItemsProcessed + 1; $k < $n; $k++) {
             if (isset($optionsLI["L_TAXAMT{$k}"])) {
                 unset($optionsLI["L_TAXAMT{$k}"]);
             }
         }
     }
     // check subtotals
     if (strval($optionsST['ITEMAMT']) > 0 && strval($subTotalLI) > 0 && strval($subTotalLI) != strval($optionsST['ITEMAMT']) || strval($subTotalLI) - strval($sumOfLineItems) != 0) {
         $this->zcLog('getLineItemDetails 5', 'Line-item subtotals do not add up properly. Line-item-details skipped.' . "\n" . (double) $sumOfLineItems . ' ' . (double) $subTotalTax . print_r(array_merge($optionsST, $optionsLI), true));
         $optionsLI = array();
     }
     // check whether discounts are causing a problem
     if (strval($optionsST['ITEMAMT']) < 0) {
         $pre = array_merge($optionsST, $optionsLI);
         $optionsLI = array();
         $optionsST['ITEMAMT'] = $optionsST['AMT'];
         if ($optionsST['AMT'] < $optionsST['TAXAMT']) {
             $optionsST['TAXAMT'] = 0;
         }
         if ($optionsST['AMT'] < $optionsST['SHIPPINGAMT']) {
             $optionsST['SHIPPINGAMT'] = 0;
         }
         $discountProblemsFlag = TRUE;
         $this->zcLog('getLineItemDetails 6', 'Discounts have caused the subtotal to calculate incorrectly. Line-item-details cannot be submitted.' . "\nBefore:" . print_r($pre, TRUE) . "\nAfter:" . print_r(array_merge($optionsST, $optionsLI), true));
     }
     // if AMT or ITEMAMT values are 0 (ie: certain OT modules disabled) or we've started express checkout without going through normal checkout flow, we have to get subtotals manually
     if ((!isset($optionsST['AMT']) || $optionsST['AMT'] == 0 || $flagSubtotalsUnknownYet == TRUE || $optionsST['ITEMAMT'] == 0) && $discountProblemsFlag != TRUE) {
         $optionsST['ITEMAMT'] = $sumOfLineItems;
         $optionsST['TAXAMT'] = $sumOfLineTax;
         if ($subTotalShipping > 0) {
             $optionsST['SHIPPINGAMT'] = $subTotalShipping;
         }
         $optionsST['AMT'] = $sumOfLineItems + $optionsST['TAXAMT'] + $optionsST['SHIPPINGAMT'];
     }
     $this->zcLog('getLineItemDetails 7 - subtotal comparisons', 'BEFORE line-item calcs: ' . print_r($subtotalPRE, true) . ($flagSubtotalsUnknownYet == TRUE ? 'Subtotals Unknown Yet' : '') . ' - AFTER doing line-item calcs: ' . print_r(array_merge($optionsST, $optionsLI, $optionsNB), true));
     // if subtotals are not adding up correctly, then skip sending any line-item or subtotal details to PayPal
     $stAll = round(strval($optionsST['ITEMAMT'] + $optionsST['TAXAMT'] + $optionsST['SHIPPINGAMT'] + $optionsST['SHIPDISCAMT'] + $optionsST['HANDLINGAMT'] + $optionsST['INSURANCEAMT']), 2);
     $stDiff = strval($optionsST['AMT'] - $stAll);
     $stDiffRounded = strval($stAll - round($optionsST['AMT'], 2)) + 0;
     // unset any subtotal values that are zero
     if (isset($optionsST['ITEMAMT']) && $optionsST['ITEMAMT'] == 0) {
         unset($optionsST['ITEMAMT']);
     }
     if (isset($optionsST['TAXAMT']) && $optionsST['TAXAMT'] == 0) {
         unset($optionsST['TAXAMT']);
     }
     if (isset($optionsST['SHIPPINGAMT']) && $optionsST['SHIPPINGAMT'] == 0) {
         unset($optionsST['SHIPPINGAMT']);
     }
     if (isset($optionsST['SHIPDISCAMT']) && $optionsST['SHIPDISCAMT'] == 0) {
         unset($optionsST['SHIPDISCAMT']);
     }
     if (isset($optionsST['HANDLINGAMT']) && $optionsST['HANDLINGAMT'] == 0) {
         unset($optionsST['HANDLINGAMT']);
     }
     if (isset($optionsST['INSURANCEAMT']) && $optionsST['INSURANCEAMT'] == 0) {
         unset($optionsST['INSURANCEAMT']);
     }
     // tidy up all values so that they comply with proper format (number_format(xxxx,2) for PayPal US use )
     if (!defined('PAYPALWPP_SKIP_LINE_ITEM_DETAIL_FORMATTING') || PAYPALWPP_SKIP_LINE_ITEM_DETAIL_FORMATTING != 'true' || in_array($order->info['currency'], array('JPY', 'NOK'))) {
         if (is_array($optionsST)) {
             foreach ($optionsST as $key => $value) {
                 $optionsST[$key] = number_format($value, $order->info['currency'] == 'JPY' ? 0 : 2);
             }
         }
         if (is_array($optionsLI)) {
             foreach ($optionsLI as $key => $value) {
                 if (substr($key, 0, 8) == 'L_TAXAMT' && ($optionsLI[$key] == '' || $optionsLI[$key] == 0)) {
                     unset($optionsLI[$key]);
                 } else {
                     if (strstr($key, 'AMT')) {
                         $optionsLI[$key] = number_format($value, $order->info['currency'] == 'JPY' ? 0 : 2);
                     }
                 }
             }
         }
     }
     $this->zcLog('getLineItemDetails 8', 'checking subtotals... ' . "\n" . print_r(array_merge(array('calculated total' => number_format($stAll, $order->info['currency'] == 'JPY' ? 0 : 2)), $optionsST), true) . "\n-------------------\ndifference: " . ($stDiff + 0) . '  (abs+rounded: ' . ($stDiffRounded + 0) . ')');
     if ($stDiffRounded != 0) {
         $this->zcLog('getLineItemDetails 9', 'Subtotals Bad. Skipping line-item/subtotal details');
         return array();
     }
     $this->zcLog('getLineItemDetails 10', 'subtotals balance - okay');
     // Send Subtotal and LineItem results back to be submitted to PayPal
     return array_merge($optionsST, $optionsLI, $optionsNB);
 }
Beispiel #7
0
function zen_image($src, $alt = '', $width = '', $height = '', $parameters = '')
{
    global $template_dir;
    // soft clean the alt tag
    $alt = zen_clean_html($alt);
    // use old method on template images
    if (strstr($src, 'includes/templates') or strstr($src, 'includes/languages') or PROPORTIONAL_IMAGES_STATUS == '0') {
        return zen_image_OLD($src, $alt, $width, $height, $parameters);
    }
    //auto replace with defined missing image
    if ($src == DIR_WS_IMAGES and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
        $src = DIR_WS_IMAGES . PRODUCTS_IMAGE_NO_IMAGE;
    }
    if ((empty($src) || $src == DIR_WS_IMAGES) && IMAGE_REQUIRED == 'false') {
        return false;
    }
    // if not in current template switch to template_default
    if (!file_exists($src)) {
        $src = str_replace(DIR_WS_TEMPLATES . $template_dir, DIR_WS_TEMPLATES . 'template_default', $src);
    }
    // alt is added to the img tag even if it is null to prevent browsers from outputting
    // the image filename as default
    $image = '<img src="' . zen_output_string($src) . '" alt="' . zen_output_string($alt) . '"';
    if (zen_not_null($alt)) {
        $image .= ' title=" ' . zen_output_string($alt) . ' "';
    }
    $srcPath = BIT_ROOT_PATH . $src;
    if (CONFIG_CALCULATE_IMAGE_SIZE == 'true' && (empty($width) || empty($height))) {
        if ($image_size = @getimagesize($srcPath)) {
            if (empty($width) && zen_not_null($height)) {
                $ratio = $height / $image_size[1];
                $width = $image_size[0] * $ratio;
            } elseif (zen_not_null($width) && empty($height)) {
                $ratio = $width / $image_size[0];
                $height = $image_size[1] * $ratio;
            } elseif (empty($width) && empty($height)) {
                $width = $image_size[0];
                $height = $image_size[1];
            }
        } elseif (IMAGE_REQUIRED == 'false') {
            return false;
        }
    }
    if (zen_not_null($width) && zen_not_null($height) and file_exists($srcPath)) {
        //      $image .= ' width="' . zen_output_string($width) . '" height="' . zen_output_string($height) . '"';
        // proportional images
        $image_size = @getimagesize($srcPath);
        // fix division by zero error
        $ratio = $image_size[0] != 0 ? $width / $image_size[0] : 1;
        if ($image_size[1] * $ratio > $height) {
            $ratio = $height / $image_size[1];
            $width = $image_size[0] * $ratio;
        } else {
            $height = $image_size[1] * $ratio;
        }
        $image .= ' width="' . $width . '" height="' . $height . '"';
    } else {
        // override on missing image to allow for proportional and required/not required
        if (IMAGE_REQUIRED == 'false') {
            return false;
        } else {
            //         $image .= ' width="' . SMALL_IMAGE_WIDTH . '" height="' . SMALL_IMAGE_HEIGHT . '"';
        }
    }
    if (zen_not_null($parameters)) {
        $image .= ' ' . $parameters;
    }
    $image .= ' />';
    return $image;
}
&nbsp;</td>
      	    <td class="pageHeading" valign="top">&nbsp;
              <input type="hidden" name="products_id" value="<?php 
            echo $products_filter;
            ?>
">
              <input type="hidden" name="current_category_id" value="<?php 
            echo $current_category_id;
            ?>
">
      	      <?php 
            $show_model = zen_get_products_model($products_filter);
            if (!empty($show_model)) {
                $show_model = " - (" . $show_model . ")";
            }
            echo zen_clean_html(zen_get_products_name($products_filter)) . $show_model;
            ?>
      	    </td>
          </tr></table></td></tr>
          <tr class="attributeBoxContent"><td><table><tr>
            <td class="attributeBoxContent" width="40">&nbsp;</td>
            <td class="attributeBoxContent">&nbsp;<?php 
            echo TABLE_HEADING_OPT_NAME . '<br />';
            ?>
              <select name="options_id" id="OptionName" onChange="update_option(this.form)" size="<?php 
            echo $action != 'delete_attribute' ? "15" : "1";
            ?>
">
<?php 
            $options_values = $db->Execute("select * from " . TABLE_PRODUCTS_OPTIONS . "\n                                    where language_id = '" . (int) $_SESSION['languages_id'] . "'\n                                    order by products_options_name");
            while (!$options_values->EOF) {
    ?>
"  target="_blank">
			  <?php 
    echo zen_trunc_string($blog_article['title'], 30, true);
    ?>
			</a>
		   </b>
		</p>
		<p>
		   <i>
			   <a href="<?php 
    echo $blog_article['blog_link'];
    ?>
" target="_blank">
				  "<?php 
    echo zen_trunc_string(zen_clean_html($blog_article['content']), 50, true);
    ?>
"
			   </a>
		   </i>
		</p>
		<p class="red">
			<?php 
    echo zen_not_null($blog_article['author']) ? $blog_article['author'] : '';
    ?>
 
			<?php 
    echo $blog_article['date'];
    ?>
		</p>
	<?php 
Beispiel #10
0
                    }
                    break;
            }
            $list_box_contents[$rows][$col] = array('align' => $lc_align, 'params' => 'class="productListing-data"', 'text' => $lc_text);
        }
        // add description and match alternating colors
        if (PRODUCT_LIST_DESCRIPTION > 0) {
            $rows++;
            if ($extra_row == 1) {
                $list_box_description = "productListing-data-description-even";
                $extra_row = 0;
            } else {
                $list_box_description = "productListing-data-description-odd";
                $extra_row = 1;
            }
            $list_box_contents[$rows][] = array('params' => 'class="' . $list_box_description . '" colspan="' . $zc_col_count_description . '"', 'text' => zen_trunc_string(zen_clean_html(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id'])), PRODUCT_LIST_DESCRIPTION));
        }
        $listing->MoveNext();
    }
    $error_categories == false;
} else {
    $list_box_contents = array();
    $list_box_contents[0] = array('params' => 'class="productListing-odd"');
    $list_box_contents[0][] = array('params' => 'class="productListing-data"', 'text' => TEXT_NO_PRODUCTS);
    $error_categories = true;
}
if ($how_many > 0 and $show_submit == 'true' and $listing_split->number_of_rows > 0 and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 1 or PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 3)) {
    $show_top_submit_button = 'true';
}
if ($how_many > 0 and $show_submit == 'true' and $listing_split->number_of_rows > 0 and PRODUCT_LISTING_MULTIPLE_ADD_TO_CART >= 2) {
    $show_bottom_submit_button = 'true';
<?php

if (isset($_GET['products_id']) && is_numeric($_GET['products_id']) && isset($products_acc_model) && zen_not_null($products_acc_model)) {
    $p_acce_models = explode(',', zen_clean_html($products_acc_model));
    $p_acce_models_str = '';
    foreach ($p_acce_models as $model) {
        $p_acce_models_str .= '"' . $model . '",';
    }
    $p_acce_models_str = substr($p_acce_models_str, 0, strlen($p_acce_models_str) - 1);
    $p_accessories_query = "select distinct p.products_id, \n\t\t\t\t\t\t\t\t\t\t\t\t\t pd.products_name,\n\t\t\t\t\t\t\t\t\t\t\t         p.products_image \n\t\t\t\t\t\t\t\t\t from " . TABLE_PRODUCTS . " p, \n\t\t\t\t\t\t\t\t\t      " . TABLE_PRODUCTS_DESCRIPTION . " pd, \n\t\t\t\t\t\t\t\t\t\t  " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, \n\t\t\t\t\t\t\t\t\t\t  " . TABLE_CATEGORIES . " c\n\t\t\t\t\t\t\t\t\t where p.products_status = '1'\n\t\t\t\t\t\t\t\t\t and   p.products_id = pd.products_id\n\t\t\t\t\t\t\t\t\t and   pd.language_id = '" . (int) $_SESSION['languages_id'] . "'\n\t\t\t\t\t\t\t\t\t and   p.products_id = p2c.products_id\n\t\t\t\t\t\t\t\t\t and   p.products_id!=" . (int) $_GET['products_id'] . " \n\t\t\t\t\t\t\t\t\t and   p2c.categories_id = c.categories_id\t\n\t\t\t\t\t\t\t\t\t and   c.categories_status='1'\n\t\t\t\t\t\t\t\t\t and   p.products_model in(" . $p_acce_models_str . ")\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t order by p.products_ordered,pd.products_name";
    $p_accessories = $db->Execute($p_accessories_query);
    if ($p_accessories->RecordCount() >= 0) {
        $rows = 0;
        $show_product_accessories = true;
        $products_accessories = array();
        while (!$p_accessories->EOF) {
            $rows++;
            $products_accessories[$rows]['id'] = $p_accessories->fields['products_id'];
            $products_accessories[$rows]['image'] = $p_accessories->fields['products_image'];
            $products_accessories[$rows]['name'] = $p_accessories->fields['products_name'];
            $p_accessories->MoveNext();
        }
    }
}
Beispiel #12
0
 $lc_align = '';
 switch ($column_list[$col]) {
     case 'PRODUCT_LIST_MODEL':
         $lc_align = '';
         $lc_text = $listing->fields['products_model'];
         break;
     case 'PRODUCT_LIST_NAME':
         $lc_align = '';
         if (isset($_GET['manufacturers_id'])) {
             $lc_text = '<a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'manufacturers_id=' . $_GET['manufacturers_id'] . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a>';
         } else {
             $lc_text = '<a href="' . CommerceProduct::getDisplayUrlFromId($listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a>';
         }
         // add description
         if (PRODUCT_LIST_DESCRIPTION > 0) {
             $lc_text .= '<div>' . zen_trunc_string(zen_clean_html(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id'])), PRODUCT_LIST_DESCRIPTION) . '</div>';
         }
         break;
     case 'PRODUCT_LIST_MANUFACTURER':
         $lc_align = '';
         $lc_text = '&nbsp;<a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '">' . $listing->fields['manufacturers_name'] . '</a>&nbsp;';
         break;
     case 'PRODUCT_LIST_PRICE':
         $lc_price = CommerceProduct::getDisplayPriceFromHash($listing->fields['products_id']) . '<br />';
         $lc_align = 'right';
         $lc_text = '&nbsp;' . $lc_price . '&nbsp;';
         // more info in place of buy now
         $lc_button = '';
         if ($listing->fields['products_priced_by_attribute'] || PRODUCT_LIST_PRICE_BUY_NOW == '0' || zen_has_product_attributes($listing->fields['products_id'])) {
             $lc_button = '<a href="' . CommerceProduct::getDisplayUrlFromId($listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
         } else {
            case $page_query_ez->fields['alt_url'] != '' and $page_query_ez->fields['page_open_new_window'] == '1':
                $page_query_list['altURL'] = substr($page_query_ez->fields['alt_url'], 0, 4) == 'http' ? $page_query_ez->fields['alt_url'] : ($page_query_ez->fields['alt_url'] == '' ? '' : zen_href_link($page_query_ez->fields['alt_url'], '', $page_query_ez->fields['page_is_ssl'] == '0' ? 'NONSSL' : 'SSL', true, true, true));
                break;
                // internal link same window
            // internal link same window
            case $page_query_ez->fields['alt_url'] != '' and $page_query_ez->fields['page_open_new_window'] == '0':
                $page_query_list['altURL'] = substr($page_query_ez->fields['alt_url'], 0, 4) == 'http' ? $page_query_ez->fields['alt_url'] : ($page_query_ez->fields['alt_url'] == '' ? '' : zen_href_link($page_query_ez->fields['alt_url'], '', $page_query_ez->fields['page_is_ssl'] == '0' ? 'NONSSL' : 'SSL', true, true, true));
                break;
        }
        // if altURL is specified, use it; otherwise, use EZPage ID to create link
        $page_query_list['link'] = $page_query_list['altURL'] == '' ? zen_href_link(FILENAME_EZPAGES, 'id=' . $page_query_ez->fields['pages_id'] . ($page_query_ez->fields['toc_chapter'] > 0 ? '&chapter=' . $page_query_ez->fields['toc_chapter'] : ''), $page_query_ez->fields['page_is_ssl'] == '0' ? 'NONSSL' : 'SSL') : $page_query_list['altURL'];
        $page_query_list['link'] .= $page_query_ez->fields['page_open_new_window'] == '1' ? '" target="_blank' : '';
        // En of get EZpage URL
        $lc_align = 'left';
        $lc_text1 = '<a href="' . $page_query_list['link'] . '">' . $page_query_ez->fields['pages_title'] . '</a>';
        $lc_text2 = '<div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes($page_query_ez->fields['pages_html_text']))) . '</div>';
        $list_box_contents[$rows][1] = array('align' => $lc_align, 'params' => 'class="productListing-data"', 'text' => $lc_text1);
        $list_box_contents[$rows][2] = array('align' => $lc_align, 'params' => 'class="productListing-data"', 'text' => $lc_text2);
        $page_query_ez->MoveNext();
    }
}
?>

<?php 
if ($listing_split->number_of_rows > 0 && (PREV_NEXT_BAR_LOCATION == '1' || PREV_NEXT_BAR_LOCATION == '3')) {
    ?>
  <div class="clearfix">
    <div id="productsListingTopNumber" class="navSplitPagesResult pull-left"><?php 
    echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_XX_OF_YY);
    ?>
</div>
>
<head>
<title><?php 
    echo zen_clean_html(META_TAG_TITLE);
    ?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php 
    echo CHARSET;
    ?>
" />
<meta name="keywords" content="<?php 
    echo zen_clean_html(META_TAG_KEYWORDS);
    ?>
" />
<meta name="description" content="<?php 
    echo zen_clean_html(META_TAG_DESCRIPTION);
    ?>
" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="author" content="The Zen Cart&trade; Team and others" />
<meta name="generator" content="shopping cart program by Zen Cart&trade;, http://www.zen-cart.com eCommerce" />
<?php 
    if (defined('ROBOTS_PAGES_TO_SKIP') && in_array($current_page_base, explode(",", constant('ROBOTS_PAGES_TO_SKIP'))) || $current_page_base == 'down_for_maintenance' || $robotsNoIndex === true) {
        ?>
<meta name="robots" content="noindex, nofollow" />
<?php 
    }
    if (defined('FAVICON')) {
        ?>
<link rel="icon" href="<?php 
        echo FAVICON;
 * @package templateSystem
 * @copyright Portions Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: block_hogehoge.php $
 */
$pId = $_GET['products_id'];
if (count($pId)) {
    ?>
<div id="multi_image_view_thmb" class="centeredContent">
<?php 
    if (count($multi_images) > 1) {
        $img_alt = zen_get_products_name($pId);
        $href_title = $img_alt . '(' . zen_get_products_display_price($pId) . ')';
        $img_alt = htmlspecialchars(zen_clean_html($img_alt), ENT_QUOTES);
        $href_title = htmlspecialchars(zen_clean_html($href_title), ENT_QUOTES);
        $thmb_cnt = 1;
        $image_cnt = -1;
        $str_splt = '';
        $pre_url = '';
        foreach ($multi_images as $item) {
            if ($image_cnt == -1) {
                $str_style = 'selected_thmb ';
            } else {
                $str_style = '';
            }
            ?>
    <div class="<?php 
            echo $str_style;
            ?>
 back<?php 
			<?php 
if (zen_not_null($products_image)) {
    require $template->get_template_dir('tpl_modules_main_product_image.php', DIR_WS_TEMPLATE, $current_page_base, 'templates') . '/tpl_modules_main_product_image.php';
}
?>
			<!--eof Main Product Image-->	
            
            	
			<div class="info">			     
				 <p class="info_p1">
				    <strong><?php 
echo TEXT_PRODUCTS_SHORT_DESC;
?>
</strong>
					<?php 
echo zen_clean_html($products_short_description);
?>
				 </p>
				 <p class="info_p2">
				    <span class="span_l"><?php 
echo TEXT_PRODUCT_MODEL;
?>
 <?php 
echo $products_afterbuy_model;
?>
</span>
					<span class="span_r">
						<?php 
//echo zen_image(DIR_WS_TEMPLATE_IMAGES.'gif_logo2.png',"Vertified",100,57,' class="align_middle"');
?>
                        <img title="Proof of Safety" alt="Security Testing" src="includes/templates/blackcool/images/renzhen.gif">
Beispiel #17
0
        $advanced_search->MoveNext();
        $row++;
    }
}
$advanced_search_split2 = new splitPageResults($listing_sql2, isset($_GET['pagesize']) ? $_GET['pagesize'] : MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');
$advanced_search2 = $db->Execute($advanced_search_split2->sql_query);
if ($advanced_search2->RecordCount() > 0) {
    $row = 0;
    while (!$advanced_search2->EOF) {
        if ($advanced_search2->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) {
            $list_box_contents2[$row]['products_image'] = '';
        } else {
            $list_box_contents2[$row]['products_image'] = $advanced_search2->fields['products_image'];
        }
        $list_box_contents2[$row]['products_name'] = $advanced_search2->fields['products_name'];
        $list_box_contents2[$row]['products_description'] = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($advanced_search2->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION);
        $list_box_contents2[$row]['products_price'] = zen_get_products_base_price($advanced_search2->fields['products_id']);
        $list_box_contents2[$row]['actual_price'] = $currencies->display_price(zen_get_products_actual_price($advanced_search2->fields['products_id']), zen_get_tax_rate($product_check->fields['products_tax_class_id']));
        $list_box_contents2[$row]['products_status'] = $advanced_search2->fields['products_status'];
        if ($advanced_search2->fields['product_is_always_free_shipping'] == 0) {
            $list_box_contents2[$row]['product_is_always_free_shipping'] = '';
        } else {
            $list_box_contents2[$row]['product_is_always_free_shipping'] = '<span class="free_shipping"></span>';
        }
        $list_box_contents2[$row]['products_quantity_order_min'] = $advanced_search2->fields['products_quantity_order_min'];
        $list_box_contents2[$row]['products_id'] = $advanced_search2->fields['products_id'];
        $list_box_contents2[$row]['products_quantity'] = $advanced_search2->fields['products_quantity'];
        $list_box_contents2[$row]['products_price_retail'] = $currencies->display_price($advanced_search2->fields['products_price_retail'], zen_get_tax_rate($product_check->fields['products_tax_class_id']));
        $list_box_contents2[$row]['products_price_sample'] = $currencies->display_price($advanced_search2->fields['products_price_sample'], zen_get_tax_rate($product_check->fields['products_tax_class_id']));
        $list_box_contents2[$row]['product_is_wholesale'] = $advanced_search2->fields['product_is_wholesale'];
        $list_box_contents2[$row]['product_wholesale_min'] = $advanced_search2->fields['product_wholesale_min'];
Beispiel #18
0
     $list_box_contents[$rows] = array('params' => 'class="productListing-odd"');
 }
 $cur_row = sizeof($list_box_contents) - 1;
 for ($col = 0, $n = sizeof($column_list); $col < $n; $col++) {
     $lc_align = '';
     switch ($column_list[$col]) {
         case 'PRODUCT_LIST_MODEL':
             $lc_align = '';
             $lc_text = $listing->fields['products_model'];
             break;
         case 'PRODUCT_LIST_NAME':
             $lc_align = '';
             if (isset($_GET['manufacturers_id'])) {
                 $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
             } else {
                 $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
             }
             break;
         case 'PRODUCT_LIST_MANUFACTURER':
             $lc_align = '';
             $lc_text = '<a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '">' . $listing->fields['manufacturers_name'] . '</a>';
             break;
         case 'PRODUCT_LIST_PRICE':
             $lc_price = '<span class="table-price">' . zen_get_products_display_price($listing->fields['products_id']) . '</span><br />';
             $lc_align = 'right';
             $lc_text = $lc_price;
             // more info in place of buy now
             $lc_button = '';
             if (zen_has_product_attributes($listing->fields['products_id']) or PRODUCT_LIST_PRICE_BUY_NOW == '0') {
                 $lc_button = '<span class="more-info"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? $_GET['cPath'] : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a></span>';
             } else {
 function convert_product_result($fields)
 {
     $fields['path_image'] = self::get_product_path_image($fields);
     $fields['name'] = $fields['products_name'];
     $fields['url'] = zen_href_link(zen_get_info_page($fields['products_id']), 'products_id=' . $fields['products_id'] . '&categories_id=' . $this->search_params['categories_id']);
     $fields['description'] = zen_trunc_string(zen_clean_html(stripslashes($fields['products_description']), PRODUCT_LIST_DESCRIPTION));
     $fields['model'] = $fields['products_model'];
     $fields['quantity'] = $fields['products_quantity'];
     $fields['date_added'] = zen_date_long($fields['products_date_added']);
     $fields['price'] = $fields['products_price'];
     #FIXME
     $fields['final_price'] = zen_get_products_display_price($fields['products_id']);
     $fields['cart_button'] = self::get_product_cart_button($fields);
     $categories = self::get_product_categories($fields['products_id']);
     foreach ($categories as $category_id) {
         $fields['categories_path'][] = self::get_categories_path($category_id, self::get_super_products_list_link('results'));
     }
     $fields['always_free_shipping'] = $fields['product_is_always_free_shipping'];
     return $fields;
 }
         } else {
             $link = '<a href="' . zen_href_link(FILENAME_PRODUCTS_NEW, zen_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new->fields['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_BUY_NOW, BUTTON_BUY_NOW_ALT) . '</a>&nbsp;';
         }
     }
     $the_button = $link;
     $products_link = '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($products_new->fields['master_categories_id']) . '&products_id=' . $products_new->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
     $display_products_button = zen_get_buy_now_button($products_new->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($products_new->fields['products_id']) . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_BUY_NOW, 3, 1));
 } else {
     $link = '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($products_new->fields['master_categories_id']) . '&products_id=' . $products_new->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
     $the_button = $link;
     $products_link = '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($products_new->fields['master_categories_id']) . '&products_id=' . $products_new->fields['products_id']) . '">' . MORE_INFO_TEXT . '</a>';
     $display_products_button = zen_get_buy_now_button($products_new->fields['products_id'], $the_button, $products_link) . '<br />' . zen_get_products_quantity_min_units_display($products_new->fields['products_id']) . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_BUY_NOW, 3, 1));
 }
 if (PRODUCT_NEW_LIST_DESCRIPTION > '0') {
     $disp_text = zen_get_products_description($products_new->fields['products_id']);
     $disp_text = zen_clean_html($disp_text);
     $display_products_description = stripslashes(zen_trunc_string($disp_text, PRODUCT_NEW_LIST_DESCRIPTION, '<a href="' . zen_href_link(zen_get_info_page($products_new->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($products_new->fields['master_categories_id']) . '&products_id=' . $products_new->fields['products_id']) . '"> ' . MORE_INFO_TEXT . '</a>'));
 } else {
     $display_products_description = '';
 }
 ?>
   <ul class="list_product clear">
     <li class="relative"><?php 
 echo $display_products_image;
 ?>
       
     </li>
     <li class="li_con">
       <dl>
         <dt><?php 
 echo $display_products_name;
 * @copyright Portions Copyright 2003 osCommerce
 */
if (!defined('IS_ADMIN_FLAG')) {
    die('Illegal Access');
}
$show_submit = zen_run_normal();
$listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');
$zco_notifier->notify('NOTIFY_MODULE_PRODUCT_LISTING_RESULTCOUNT', $listing_split->number_of_rows);
$how_many = 0;
$tpl_products = array('title' => '', 'products' => array());
if ($listing_split->number_of_rows > 0) {
    $listing = $db->Execute($listing_split->sql_query, false, true, CACHE_TIMELIFT);
    while (!$listing->EOF) {
        $the_categories_name_query = "select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id= '" . $listing->fields['master_categories_id'] . "' and language_id= '" . $_SESSION['languages_id'] . "'";
        $the_categories_name = $db->Execute($the_categories_name_query, null, true, CACHE_TIMELIFT);
        $tpl_products['products'][$listing->fields['products_id']] = array('name' => $listing->fields['products_name'], 'image' => $listing->fields['products_image'], 'quantity' => $listing->fields['products_quantity'], 'weight' => $listing->fields['products_weight'], 'type' => $listing->fields['products_type'], 'categories_id' => $listing->fields['master_categories_id'], 'categories_name' => $the_categories_name->fields['categories_name'], 'categories_href' => zen_href_link(FILENAME_DEFAULT, 'cPath=' . $listing->fields['master_categories_id']), 'manufacturers_id' => $listing->fields['manufacturers_id'], 'products_price' => $listing->fields['products_price'], 'tax_class_id' => $listing->fields['products_tax_class_id'], 'description' => zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION), 'content' => $listing->fields['products_description'], 'specials_price' => $listing->fields['specials_new_products_price'], 'final_price' => $listing->fields['final_price'], 'sort_order' => $listing->fields['products_sort_order'], 'is_call' => $listing->fields['product_is_call'], 'is_always_free_shipping' => $listing->fields['product_is_always_free_shipping'], 'qty_box_status' => $listing->fields['products_qty_box_status'], 'href' => zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']), 'display_price' => zen_get_products_display_price($listing->fields['products_id']), 'is_free' => get_product_is_free($listing->fields['products_id']), 'display_normal_price' => get_normal_price($listing->fields['products_id']), 'display_special_price' => get_special_price($listing->fields['products_id']), 'display_sale_price' => get_sale_discount_price($listing->fields['products_id']));
        if (PRODUCT_LIST_MANUFACTURER != 0) {
            $tpl_products['products'][$listing->fields['products_id']]['show_manufacturer'] = true;
            $tpl_products['products'][$listing->fields['products_id']]['manufacturers_name'] = $listing->fields['manufacturers_name'];
            $tpl_products['products'][$listing->fields['products_id']]['manufacturers_href'] = zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']);
        }
        $listing->MoveNext();
    }
    $error_categories = false;
} else {
    $tpl_products = array('title' => '', 'products' => array());
    $error_categories = true;
}
$multiple_buy = false;
if ($how_many > 0 and $show_submit == true and $listing_split->number_of_rows > 0 and (PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 1 or PRODUCT_LISTING_MULTIPLE_ADD_TO_CART == 3)) {
    $show_top_submit_button = true;
 /**
  * Prepare subtotal and line-item detail content to send to PayPal
  */
 function getLineItemDetails()
 {
     global $order, $currencies, $order_totals, $order_total_modules;
     $optionsST = array();
     $optionsLI = array();
     $onetimeSum = 0;
     $onetimeTax = 0;
     $creditsApplied = 0;
     $creditsTax_applied = 0;
     $sumOfLineItems = 0;
     $sumOfLineTax = 0;
     // prepare subtotals
     for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
         if ($order_totals[$i]['code'] == 'ot_subtotal') {
             $optionsST['ITEMAMT'] = round($order_totals[$i]['value'], 2);
         }
         if ($order_totals[$i]['code'] == 'ot_tax') {
             $optionsST['TAXAMT'] = round($order_totals[$i]['value'], 2);
         }
         if ($order_totals[$i]['code'] == 'ot_shipping') {
             $optionsST['SHIPPINGAMT'] = round($order_totals[$i]['value'], 2);
         }
         if ($order_totals[$i]['code'] == 'ot_total') {
             $optionsST['AMT'] = round($order_totals[$i]['value'], 2);
         }
         $optionsST['HANDLINGAMT'] = 0;
         global ${$order_totals[$i]['code']};
         if (isset(${$order_totals[$i]['code']}->credit_class) && ${$order_totals[$i]['code']}->credit_class == true) {
             $creditsApplied += round($order_totals[$i]['value'], 2);
         }
         // treat all other OT's as if they're related to handling fees
         if (!in_array($order_totals[$i]['code'], array('ot_total', 'ot_subtotal', 'ot_tax', 'ot_shipping')) && !(isset(${$order_totals[$i]['code']}->credit_class) && ${$order_totals[$i]['code']}->credit_class == true)) {
             $optionsST['HANDLINGAMT'] += $order_totals[$i]['value'];
         }
     }
     // Move shipping tax amount from Tax subtotal into Shipping subtotal for submission to PayPal
     $module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_'));
     if (zen_not_null($order->info['shipping_method'])) {
         if ($GLOBALS[$module]->tax_class > 0) {
             $shipping_tax_basis = !isset($GLOBALS[$module]->tax_basis) ? STORE_SHIPPING_TAX_BASIS : $GLOBALS[$module]->tax_basis;
             $shippingOnBilling = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']);
             $shippingOnDelivery = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
             if ($shipping_tax_basis == 'Billing') {
                 $shipping_tax = $shippingOnBilling;
             } elseif ($shipping_tax_basis == 'Shipping') {
                 $shipping_tax = $shippingOnDelivery;
             } else {
                 if (STORE_ZONE == $order->billing['zone_id']) {
                     $shipping_tax = $shippingOnBilling;
                 } elseif (STORE_ZONE == $order->delivery['zone_id']) {
                     $shipping_tax = $shippingOnDelivery;
                 } else {
                     $shipping_tax = 0;
                 }
             }
             $taxAdjustmentForShipping = zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
             $optionsST['SHIPPINGAMT'] += $taxAdjustmentForShipping;
             $optionsST['TAXAMT'] -= $taxAdjustmentForShipping;
         }
     }
     // loop thru all products to display quantity and price. Appends *** if out-of-stock.
     for ($i = 0, $n = sizeof($order->products), $k = 0; $i < $n; $i++, $k++) {
         $optionsLI["L_NUMBER{$k}"] = $order->products[$i]['model'];
         $optionsLI["L_QTY{$k}"] = (int) $order->products[$i]['qty'];
         $optionsLI["L_NAME{$k}"] = $order->products[$i]['name'];
         $optionsLI["L_NAME{$k}"] .= zen_get_products_stock($order->products[$i]['id']) - $order->products[$i]['qty'] < 0 ? STOCK_MARK_PRODUCT_OUT_OF_STOCK : '';
         // if there are attributes, loop thru them and add to description
         if (isset($order->products[$i]['attributes']) && sizeof($order->products[$i]['attributes']) > 0) {
             for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) {
                 $optionsLI["L_NAME{$k}"] .= "\n " . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
             }
             // end loop
         }
         // endif attribute-info
         $optionsLI["L_AMT{$k}"] = $order->products[$i]['final_price'];
         $optionsLI["L_TAXAMT{$k}"] = zen_calculate_tax($order->products[$i]['final_price'], $order->products[$i]['tax']);
         // track one-time charges
         if ($order->products[$i]['onetime_charges'] != 0) {
             $onetimeSum += $order->products[$i]['onetime_charges'];
             $onetimeTax += zen_calculate_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']);
         }
         // Replace & and = with * if found.
         $optionsLI["L_NAME{$k}"] = str_replace(array('&', '='), '*', $optionsLI["L_NAME{$k}"]);
         $optionsLI["L_NAME{$k}"] = zen_clean_html($optionsLI["L_NAME{$k}"], 'strong');
         // reformat properly
         $optionsLI["L_NUMBER{$k}"] = substr($optionsLI["L_NUMBER{$k}"], 0, 127);
         $optionsLI["L_NAME{$k}"] = substr($optionsLI["L_NAME{$k}"], 0, 127);
         $optionsLI["L_AMT{$k}"] = $optionsLI["L_AMT{$k}"];
         $optionsLI["L_TAXAMT{$k}"] = round($optionsLI["L_TAXAMT{$k}"], 2);
     }
     // end for loopthru all products
     if ($onetimeSum > 0) {
         $i++;
         $k++;
         $optionsLI["L_NUMBER{$k}"] = $k;
         $optionsLI["L_NAME{$k}"] = 'One-Time Charges';
         $optionsLI["L_AMT{$k}"] = $onetimeSum;
         $optionsLI["L_TAXAMT{$k}"] = $onetimeTax;
         $optionsLI["L_QTY{$k}"] = 1;
     }
     // handle discounts such as gift certificates and coupons
     if ($creditsApplied > 0) {
         $optionsST['HANDLINGAMT'] -= $creditsApplied;
     }
     // add all one-time charges
     $optionsST['ITEMAMT'] += $onetimeSum;
     //ensure things are not negative
     $optionsST['HANDLINGAMT'] = abs(strval($optionsST['HANDLINGAMT']));
     // ensure all numbers are non-negative
     if (is_array($optionsST)) {
         foreach ($optionsST as $key => $value) {
             $optionsST[$key] = abs(strval($value));
         }
     }
     if (is_array($optionsLI)) {
         foreach ($optionsLI as $key => $value) {
             if (strstr($key, 'AMT')) {
                 $optionsLI[$key] = abs(strval($value));
             }
         }
     }
     // subtotals have to add up to AMT
     // Thus, if there is a discrepancy, make adjustment to HANDLINGAMT:
     $st = $optionsST['ITEMAMT'] + $optionsST['TAXAMT'] + $optionsST['SHIPPINGAMT'] + $optionsST['HANDLINGAMT'];
     if ($st != $optionsST['AMT']) {
         $optionsST['HANDLINGAMT'] += strval($optionsST['AMT'] - $st);
     }
     /*  //PayPal API spec contradicts itself ... and apparently neither of these "requirements" are enforced. 
         //Thus skipping this section for now:
     
         // according to API specs, these cannot be set if they contain zero values, so unset if they are zero:
         if ($optionsST['TAXAMT'] == 0)      unset($optionsST['TAXAMT']);
         if ($optionsST['SHIPPINGAMT'] == 0) unset($optionsST['SHIPPINGAMT']);
         if ($optionsST['HANDLINGAMT'] == 0) unset($optionsST['HANDLINGAMT']);
         // set missing subtotals if they are zero values, since all must be submitted
         if (!isset($optionsST['TAXAMT']))      $optionsST['TAXAMT'] = 0;
         if (!isset($optionsST['SHIPPINGAMT'])) $optionsST['SHIPPINGAMT'] = 0;
         if (!isset($optionsST['HANDLINGAMT'])) $optionsST['HANDLINGAMT'] = 0;
     */
     // Since the PayPal spec cannot handle mathematically mismatched values caused by one-time charges,
     // must drop line-item details if any one-time charges apply to this order:
     // if there are any discounts in this order, do NOT supply line-item details
     if ($onetimeSum > 0) {
         $optionsLI = array();
     }
     // Do sanity check -- if any of the line-item subtotal math doesn't add up properly, skip line-item details,
     // so that the order can go through even though PayPal isn't being flexible to handle Zen Cart's diversity
     for ($j = 0; $j < $k; $j++) {
         $itemAMT = $optionsLI["L_AMT{$j}"];
         $itemTAX = $optionsLI["L_TAXAMT{$j}"];
         $itemQTY = $optionsLI["L_QTY{$j}"];
         $sumOfLineItems += $itemQTY * $itemAMT;
         $sumOfLineTax += round($itemQTY * $itemTAX, 2);
     }
     if ((double) $optionsST['ITEMAMT'] != (double) strval($sumOfLineItems)) {
         $optionsLI = array();
         $this->zcLog('getLineItemDetails 1', 'Order Subtotal does not match sum of line-item prices. Line-item-details skipped.' . "\n" . (double) $optionsST['ITEMAMT'] . ' ' . (double) $sumOfLineItems);
         //die('ITEMAMT != $sumOfLineItems ' . $optionsST['ITEMAMT'] . ' ' . $sumOfLineItems);
     }
     if ((double) $optionsST['TAXAMT'] != (double) strval($sumOfLineTax)) {
         $optionsLI = array();
         $this->zcLog('getLineItemDetails 2', 'Tax Subtotal does not match sum of taxes for line-items. Line-item-details skipped.' . "\n" . $optionsST['TAXAMT'] . ' ' . $sumOfLineTax);
         //die('TAXAMT != $sumofLineTax ' . $optionsST['TAXAMT'] . ' ' . $sumOfLineTax);
     }
     $this->zcLog('getLineItemDetails 3', 'LineItemDetails: ' . "\n" . ($creditsApplied ? 'Credits apply to this order, so all line-item details are NOT being submitted. Thus, the following data is REDUNDANT' . "\n" : '') . 'Details:' . print_r(array_merge($optionsST, $optionsLI), true) . "\n\n" . 'DEFAULT_CURRENCY = ' . DEFAULT_CURRENCY . "\nSESSION['currency'] = " . $_SESSION['currency'] . "\n" . "order->info['currency'] = " . $order->info['currency'] . "\n\$currencies->currencies[\$_SESSION['currency']]['value'] = " . $currencies->currencies[$_SESSION['currency']]['value'] . "\n" . print_r($currencies, true));
     // if not default currency, do not send subtotals or line-item details
     if (DEFAULT_CURRENCY != $order->info['currency']) {
         $this->zcLog('getLineItemDetails 4', 'Not using default currency. Thus, no line-item details can be submitted.');
         return array();
     }
     if ($currencies->currencies[$_SESSION['currency']]['value'] != 1) {
         $this->zcLog('getLineItemDetails 5', 'currency val not equal to 1.0000 - cannot proceed without coping with currency conversions. Aborting line-item details.');
         return array();
     }
     // if there are any discounts in this order, do not supply subtotals or line-item details
     if (strval($creditsApplied) > 0) {
         return array();
     }
     //$this->zcLog('getLineItemDetails 6', 'no credits - okay');
     // if subtotals are not adding up correctly, then skip sending any line-item or subtotal details to PayPal
     $st = round(strval($optionsST['ITEMAMT'] + $optionsST['TAXAMT'] + $optionsST['SHIPPINGAMT'] + $optionsST['HANDLINGAMT']), 2);
     $stDiff = strval($optionsST['AMT'] - $st);
     $stDiffRounded = strval(abs($st) - abs(round($optionsST['AMT'], 2)));
     // tidy up all values so that they comply with proper format (number_format(xxxx,2) for PayPal US use )
     if (!defined('PAYPALWPP_SKIP_LINE_ITEM_DETAIL_FORMATTING') || PAYPALWPP_SKIP_LINE_ITEM_DETAIL_FORMATTING != 'true') {
         if (is_array($optionsST)) {
             foreach ($optionsST as $key => $value) {
                 $optionsST[$key] = number_format(abs($value), 2);
             }
         }
         if (is_array($optionsLI)) {
             foreach ($optionsLI as $key => $value) {
                 if (strstr($key, 'AMT')) {
                     $optionsLI[$key] = number_format(abs($value), 2);
                 }
             }
         }
     }
     $this->zcLog('getLineItemDetails 7', 'checking subtotals... ' . "\nitemamt: " . $optionsST['ITEMAMT'] . "\ntaxamt: " . $optionsST['TAXAMT'] . "\nshippingamt: " . $optionsST['SHIPPINGAMT'] . "\nhandlingamt: " . $optionsST['HANDLINGAMT'] . "\n-------------------\nsubtotal: " . number_format($st, 2) . "\nAMT: " . $optionsST['AMT'] . "\n-------------------\ndifference: " . $stDiff . '  (abs+rounded: ' . $stDiffRounded . ')');
     if ($stDiffRounded != 0) {
         return array();
     }
     //die('bad subtotals'); //return array();
     $this->zcLog('getLineItemDetails 8', 'subtotals balance - okay');
     if (abs($optionsST['HANDLINGAMT']) == 0) {
         unset($optionsST['HANDLINGAMT']);
     }
     // Send Subtotal and LineItem results back to be submitted to PayPal
     return array_merge($optionsST, $optionsLI);
 }
Beispiel #23
0
     $lc_align = '';
     if ($listing->fields['manufacturers_name'] != '') {
         $trg_extra_val .= '<div class="product-model">' . TABLE_HEADING_MODEL . ' : ' . $listing->fields['products_model'] . "</div>";
     }
     //$lst_lc_text = '<div class="product-model">'.$listing->fields['products_model']."</div>";
     break;
 case 'PRODUCT_LIST_NAME':
     $lc_align = '';
     if (isset($_GET['manufacturers_id'])) {
         $product_name = '<h2 class="product-name"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $products_name . '</a></h2>';
         $product_name_only = $products_name;
         $product_desc = '<div class="text"><p>' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</p></div>';
     } else {
         $product_name = '<h2 class="product-name"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $products_name . '</a></h2>';
         $product_name_only = $products_name;
         $product_desc = '<div class="text"><p>' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</p></div>';
     }
     break;
 case 'PRODUCT_LIST_MANUFACTURER':
     $lc_align = '';
     if ($listing->fields['manufacturers_name'] != '') {
         $trg_extra_val .= '<div class="product-menufacture">' . TABLE_HEADING_MANUFACTURER . ' : ' . '<span><a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '">' . $listing->fields['manufacturers_name'] . '</a></span></div>';
     }
     //$lst_lc_text = '<div class="product-menufacture"><a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing->fields['manufacturers_id']) . '">' . $listing->fields['manufacturers_name'] . '</a></div>';
     break;
 case 'PRODUCT_LIST_PRICE':
     // $lc_price = '<div class="price-box">'.zen_get_products_display_price($listing->fields['products_id']) . '</div>';
     $product_price_box = zen_mb_get_products_display_price($listing->fields['products_id']);
     $lc_align = 'right';
     $lc_text = $lc_price;
     $lst_lc_text = $lc_price;