Ejemplo n.º 1
0
                     $options_variants_user_set_array[$optVariantsLinksToProduct['variant_id']] = $optVariantsLinksToProduct['variant_id'] . "-" . $optVariantsLinksToProduct['linked_prodict_id'];
                 }
             }
         }
     }
     foreach ($optionVariantsToProductArray as $optionVariantsToProductKey => $optionVariantsToProduct) {
         $optionVariantsToProductArrayStrings[$optionVariantsToProductKey] = implode("&", $optionVariantsToProduct);
     }
     if (count($options_variants_user_set_array) > 0) {
         $options_variants_user_set_string = implode(",", $options_variants_user_set_array);
     }
     Registry::get('view')->assign('linked_product_amount', $linked_product_amount);
     Registry::get('view')->assign('options_variants_user_set', $options_variants_user_set_string);
     Registry::get('view')->assign('opts_variants_links_to_products_array', $optsVariantsLinksToProductsArray);
     Registry::get('view')->assign('option_variants_to_product_array_strings', $optionVariantsToProductArrayStrings);
     $product_variants_inventory = fn_product_variants_inventar($product['product_id'], $product['selected_options']);
     Registry::get('view')->assign('product_variants_inventory', $product_variants_inventory);
     Registry::get('view')->assign('ls_final_amount', $product['amount']);
     if (!empty($_REQUEST['appearance']['quick_view'])) {
         Registry::get('view')->assign('testviewtpl', 'its working');
         //Registry::get('view')->assign('product_image_pairs', $product['image_pairs']);
         $display_tpl = 'views/products/quick_view.tpl';
     } elseif (!empty($_REQUEST['appearance']['details_page'])) {
         $display_tpl = 'views/products/view.tpl';
     } else {
         $display_tpl = 'common/product_data.tpl';
     }
 } else {
     $display_tpl = 'views/products/components/select_product_options.tpl';
     Registry::get('view')->assign('product_options', $product['product_options']);
 }
Ejemplo n.º 2
0
function fn_ls_check_all_option_variants_inventories($product_id, $product_options = array())
{
    $options_variants_inventories = fn_product_variants_inventar($product_id, $product_options);
    $fieldsOptionsVariantsLinksToProducts = "?:product_options.option_id, c.variant_id, d.product_id AS linked_prodict_id, d.product_nr, c.set_by_user, p.amount";
    $conditionOptionsVariantsLinksToProducts = db_quote(' (?:product_options.product_id = ?i OR (?:product_options.product_id=0 AND n.product_id = ?i))', $_REQUEST['product_id'], $_REQUEST['product_id']);
    $joinOptionsVariantsLinksToProducts = db_quote(' LEFT JOIN ?:product_global_option_links n ON ?:product_options.option_id = n.option_id ');
    $joinOptionsVariantsLinksToProducts .= db_quote(' JOIN ?:product_option_variants c ON ?:product_options.option_id = c.option_id');
    $joinOptionsVariantsLinksToProducts .= db_quote(' JOIN ?:product_option_variants_link d ON c.variant_id = d.option_variant_id');
    $joinOptionsVariantsLinksToProducts .= db_quote(' JOIN ?:products p ON p.product_id = d.product_id');
    $optsVariantsLinksToProducts = db_get_array("SELECT " . $fieldsOptionsVariantsLinksToProducts . " FROM ?:product_options " . $joinOptionsVariantsLinksToProducts . " WHERE " . $conditionOptionsVariantsLinksToProducts . " GROUP BY c.variant_id, ?:product_options.option_id" . " ORDER BY ?:product_options.position, c.position");
    $optsVariantsLinksToProductsArray = array();
    $optionVariantsToProductArray = array();
    $optionVariantsToProductArrayStrings = array();
    $options_variants_user_set_array = array();
    $linked_product_amount = array();
    $cart_user_id = $_SESSION['auth']['user_id'];
    if (!$cart_user_id) {
        $cart_user_id = fn_get_session_data('cu_id');
    }
    $cartProductInfo = db_get_array("SELECT extra, amount FROM ?:user_session_products WHERE product_id =?i AND user_id=?i", $product_id, intval($cart_user_id));
    //$ordersProductInfo = db_get_array("SELECT ?:order_details.extra, ?:order_details.amount FROM ?:orders JOIN ?:order_details ON ?:order_details.order_id =?:orders.order_id WHERE ?:order_details.product_id =?i AND ?:orders.status IN ('O','B','F','P')", $product_id);
    $productTransactionsInfoArray = array();
    foreach ($cartProductInfo as $cartProductI) {
        $extraUnserializedInfo = unserialize($cartProductI["extra"]);
        foreach ($extraUnserializedInfo['product_options'] as $k1 => $v1) {
            if (isset($productTransactionsInfoArray[$v1])) {
                $productTransactionsInfoArray[$v1] += $cartProductI["amount"];
            } else {
                $productTransactionsInfoArray[$v1] = $cartProductI["amount"];
            }
        }
    }
    //var_dump($productTransactionsInfoArray);echo"<br/>_____<br/>";
    //        foreach($ordersProductInfo as $orderProductInfo){
    //            $extraUnserializedInfo = unserialize($orderProductInfo["extra"]);
    //
    //            foreach($extraUnserializedInfo['product_options'] as $k1=>$v1){
    //                if(isset($productTransactionsInfoArray[$v1])){
    //                    $productTransactionsInfoArray[$v1] += $orderProductInfo["amount"];
    //                }else{
    //                    $productTransactionsInfoArray[$v1] = $orderProductInfo["amount"];
    //                }
    //            }
    //        }
    //var_dump($productTransactionsInfoArray);echo"<br/>_____<br/>";
    foreach ($optsVariantsLinksToProducts as $optVariantsLinksToProduct) {
        if ($optVariantsLinksToProduct['amount'] >= $optVariantsLinksToProduct['product_nr']) {
            $options_variants_inventories[$optVariantsLinksToProduct['option_id']][$optVariantsLinksToProduct['variant_id']] = $optVariantsLinksToProduct['amount'] - $productTransactionsInfoArray[$optVariantsLinksToProduct['variant_id']];
        } else {
            $options_variants_inventories[$optVariantsLinksToProduct['option_id']][$optVariantsLinksToProduct['variant_id']] = 0;
        }
    }
    //var_dump($options_variants_inventories);
    return $options_variants_inventories;
}