function traverse_tree($parent_id, $depth_flag, &$tree_depth, &$tree_branches, &$branch_leafs)
{
    //control how deep the tree goes
    $depth_flag = $depth_flag + 1;
    //loop through categories at each level
    for ($i = 0; $i < $tree_branches; $i++) {
        //echo "looping through level $i categories PARENT ID: $parent_id<br>";
        $last_id = create_category($parent_id);
        //loop through how many products per category
        for ($j = 0; $j < $branch_leafs; $j++) {
            create_product($last_id);
            //echo "looping through level $j products LAST ID: $last_id<br>";
            //end foreach create product
        }
        //echo "<BR>1. DEPTH FLAG: $depth_flag PRIOR TO checking depth flag value<BR>";
        if ($depth_flag <= "{$tree_depth}") {
            //echo "<BR>2. DEPTH FLAG: $depth_flag TREE DEPTH: $tree_depth<BR>";
            traverse_tree($last_id, $depth_flag, $tree_depth, $tree_branches, $branch_leafs);
            //echo "<BR> 3. DEPTH FLAG: $depth_flag AFTER recursive traverse <BR>";
            //end if to traverse deeper
        }
        //end foreach categories at each level
    }
    //end function traverse_tree
}
function submit_products()
{
    $start = 0;
    while (true) {
        $inventories = Inventory::whereNull('shopify_id')->orWhere('dirty', 1)->skip($start)->take(100)->get();
        $cnt = count($inventories);
        if ($cnt == 0) {
            break;
        }
        foreach ($inventories as $inventory) {
            if ($inventory->image == '') {
                continue;
            }
            if ($inventory->shopify_id == NULL) {
                $amzInfo = AmazonInfo::where("inventory_id", $inventory->id)->first();
                $collection = Collection::where("name", $amzInfo->category1)->first();
                if ($collection == NULL) {
                    //echo '[', date('Y-m-d H:m:s'), '] Skip - ', $inventory->name, "\r\n";
                    continue;
                }
                $result = create_product($inventory->name, $inventory->description, 'Bellwether', 'Book', $inventory->sku, $inventory->price, $inventory->quantity, $inventory->image, $inventory->isbn);
                if ($result['success'] == 'true') {
                    /*
                    	Check if collection exists and add product & category...
                    */
                    if ($collection != NULL) {
                        $inventory->dirty = 0;
                        $sid = $result['product']['id'];
                        $inventory->shopify_id = $sid;
                        $inventory->save();
                        echo '[', date('Y-m-d H:m:s'), '] Added Product - ', "ID ", $sid, ", ", $inventory->name, "\r\n";
                        add_product_to_collection($result['product']['id'], $collection->shopify_id);
                        echo 'Added to Collection - ' . $collection->name . "\r\n";
                    }
                }
            } else {
                $result = update_product_content($inventory->shopify_id, $inventory->price, $inventory->quantity, $inventory->sku);
                if ($result['success'] == 'true') {
                    $inventory->dirty = 0;
                    $inventory->save();
                    echo 'Updated Product - ' . $inventory->name . "\r\n";
                }
            }
        }
        $start += $cnt;
    }
}
Example #3
0
         }
     } else {
         render_product_names();
         break;
     }
 case 'render':
     exit;
     break;
 case 'list':
     render_all_products(get_all_products());
     break;
 case 'new':
     render_new_product();
     break;
 case 'save':
     create_product(post('name'), post('quantity'));
     redirect($g["abs_url"] . '/inventory/');
     break;
 case 'edit':
     // Make sure productid set to edit
     if (isset($inventory_command)) {
         // Get productid to edit
         $productid = $inventory_command;
         // Check if updating product
         if (isset($_POST) && isset($_POST['name']) && isset($_POST['quantity'])) {
             $new_name = $_POST['name'];
             $quantity = $_POST['quantity'];
             edit_product($productid, $new_name, $quantity);
             echo "Update product to '" . $new_name . "' and quantity: " . $quantity;
         }
         // Show the updated product
Example #4
0
}
// Read in Every row from Distribution.csv
// Create Products in Inventory
// Add their Quantity to Each Family Size Bag
$row = 1;
if (($handle = fopen("distribution.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $num = count($data);
        echo "<p> {$num} fields in line {$row}: <br /></p>\n";
        $row++;
        // Skip title rows
        if ($row < 4) {
            continue;
        }
        echo "Create Product: " . $data[0] . "<br/>";
        $product_id = create_product($data[0], '0');
        if (!$product_id) {
            $product = get_product_by_name($data[0]);
            $product_id = $product['productid'];
        }
        for ($i = 1; $i <= 10; $i++) {
            $bag_id = $bag_ids[$i];
            $quantity = $data[$i];
            $choice = $data[11] == 'Y' ? '1' : '0';
            if ($quantity != '') {
                echo "Bag Name: " . $bag_names[$i] . " | BagID: " . $bag_id . " | Quantity: " . $quantity . "<br/>";
                create_bag_content($bag_id, $product_id, $quantity, $choice, '');
            }
        }
        /*
        		for ($c=0; $c < $num; $c++) {
Example #5
0
					html {
					color:#fff;
					background-color:#303030;
					margin:10%;
					font-size:300%;
					font-family:sans-serif;
					}
					</style>';
            echo $producttitle . " has been listed for " . $product_price . " and will be reviewed for confirmation. Please stay updated!\n\t\t\t\t\t<a href='http://submit.freelabel.net/'>Return to Dashboard</a><br><br><br><br><br><br>";
            // echo $user_name;
        } else {
            echo "Error creating database entry: " . mysqli_error($con);
        }
    }
}
create_product();
// DISPLAY SAVED PRODUCTS
include '../../../inc/connection.php';
$result = mysqli_query($con, "SELECT * FROM store WHERE user_name='" . $user_name . "' ORDER BY `id` DESC LIMIT 6");
if (mysqli_fetch_array($result) == 0) {
    echo '<p id="joinbutton">';
    echo 'You have no Products in the store.
	</p>';
}
if (mysqli_fetch_array($result)) {
    $result = mysqli_query($con, "SELECT * FROM store WHERE user_name='" . $user_name . "' ORDER BY `id` DESC LIMIT 6");
    if ($user_name_session == 'admin') {
        $result = mysqli_query($con, "SELECT * FROM store ORDER BY `id` DESC LIMIT 20");
    }
    while ($row = mysqli_fetch_array($result)) {
        $product_id = $row['id'];
function submit_products()
{
    $start = 0;
    while (true) {
        $inventories = Inventory::where('dirty', 1)->take(100)->get();
        $cnt = count($inventories);
        if ($cnt == 0) {
            break;
        }
        foreach ($inventories as $inventory) {
            if ($inventory->image == '') {
                $inventory->dirty = -3;
                $inventory->save();
                continue;
            }
            $inventory = Inventory::where('isbn', $inventory->isbn)->orderBy('price', 'asc')->first();
            Inventory::where('isbn', $inventory->isbn)->update(['dirty' => 0]);
            if ($inventory->shopify_id == NULL) {
                $amzInfo = AmazonInfo::where("inventory_id", $inventory->id)->first();
                $collection = Collection::where("name", $amzInfo->category1)->first();
                if ($amzInfo->url == null || $amzInfo->description == null) {
                    continue;
                }
                $dimension = $amzInfo->width . 'W x ' . $amzInfo->height . 'H x ' . $amzInfo->length . 'L (in)';
                $result = create_product($inventory->name, $amzInfo->description, 'Bellwether', 'Book', $inventory->sku, $inventory->price, $inventory->quantity, $inventory->image, $inventory->isbn, $amzInfo->list_price, $inventory->condition, $inventory->author, $inventory->publisher, $dimension, $amzInfo->pages, $amzInfo->url);
                print_r($result);
                if ($result['success'] == 'true') {
                    $inventory->dirty = 0;
                    $sid = $result['product']['id'];
                    $inventory->shopify_id = $sid;
                    $inventory->shopify_var_id = $result['variants'][0]['id'];
                    $inventory->save();
                    echo 'Added Product - ', "ID ", $sid, ", ", $inventory->name, "\r\n";
                    /*
                    	Add collection...
                    */
                    if ($collection != NULL) {
                        add_product_to_collection($result['product']['id'], $collection->shopify_id);
                        echo 'Added to Collection - ' . $collection->name . "\r\n";
                    }
                } else {
                    echo 'Failed Product - ', "ID ", $sid, ", ", $inventory->name, "\r\n";
                    $inventory->dirty = -1;
                    $inventory->save();
                }
            } else {
                if ($amzInfo->url == null || $amzInfo->description == null) {
                    continue;
                }
                $result = update_product_content($inventory->shopify_id, $inventory->name, $amzInfo->description, $inventory->sku, $inventory->price, $inventory->quantity, $inventory->isbn, $amzInfo->list_price, $inventory->condition, $inventory->author, $inventory->publisher, $dimension, $amzInfo->pages, $amzInfo->url);
                if ($result['success'] == 'true') {
                    $inventory->dirty = 0;
                    $inventory->save();
                    echo 'Updated Product - ' . $inventory->name . "\r\n";
                } else {
                    echo 'Failed to update Product - ' . $inventory->name . "\r\n";
                    echo json_encode($result), "r\n";
                    $inventory->dirty = -2;
                    $inventory->save();
                }
            }
            //usleep(100);
        }
        $start += $cnt;
    }
}
 function Row_Inserting($rsold, &$rsnew)
 {
     // Enter your code here
     // To cancel, set return value to FALSE
     // $last_id = create_product(1,$_POST['vente'],$_POST['achat'],$_POST['format']);
     $last_id = create_product(1);
     $rsnew['id_produit'] = $last_id;
     return TRUE;
 }
Example #8
0
/** import bag information from csv version of the excel bag contents
 */
function import_bag_content($bagid, $name, $quantity, $notes, $choice)
{
    // Create product in inventory
    $productid = create_product($name, '');
    if (!$productid) {
        $product = get_product_by_name($name);
        $productid = $product['productid'];
    }
    echo "bag: " . $bagid . " product: " . $productid . " <br/>";
    create_bag_content($bagid, $productid, $quantity, $choice, $notes);
}
Example #9
0
 function Row_Inserting($rsold, &$rsnew)
 {
     // Enter your code here
     // To cancel, set return value to FALSE
     $last_id = create_product(2);
     $rsnew['id_produit'] = $last_id;
     return TRUE;
 }