Exemplo n.º 1
0
 private function updateQty($id, $newQty)
 {
     // $id is formatted uri::variantslug::optionslug
     $idParts = explode('::', $id);
     $uri = $idParts[0];
     $variantSlug = $idParts[1];
     $optionSlug = $idParts[2];
     // Get combined quantity of this option's siblings
     $siblingsQty = 0;
     foreach ($this->data as $key => $qty) {
         if (strpos($key, $uri . '::' . $variantSlug) === 0 and $key != $id) {
             $siblingsQty += $qty;
         }
     }
     foreach (page($uri)->variants()->toStructure() as $variant) {
         if (str::slug($variant->name()) === $variantSlug) {
             // Store the stock in a variable for quicker processing
             $stock = inStock($variant);
             // If there are no siblings
             if ($siblingsQty === 0) {
                 // If there is enough stock
                 if ($stock === true or $stock >= $newQty) {
                     return $newQty;
                 } else {
                     if ($stock === false) {
                         return 0;
                     } else {
                         return $stock;
                     }
                 }
             } else {
                 // If the siblings plus $newQty won't exceed the max stock, go ahead
                 if ($stock === true or $stock >= $siblingsQty + $newQty) {
                     return $newQty;
                 } else {
                     if ($stock === false or $stock <= $siblingsQty) {
                         return 0;
                     } else {
                         if ($stock > $siblingsQty and $stock <= $siblingsQty + $newQty) {
                             return $stock - $siblingsQty;
                         }
                     }
                 }
             }
         }
     }
     // The script should never get to this point
     return 0;
 }
Exemplo n.º 2
0
            }
            ?>
									</select>
								<?php 
        }
        ?>

								<button <?php 
        e(inStock($variant), '', 'disabled');
        ?>
 class="uk-button uk-button-primary uk-width-1-1" type="submit" property="offers" typeof="Offer">
									<?php 
        echo $variant->priceText;
        ?>
									<link property="availability" href="<?php 
        e(inStock($variant), 'http://schema.org/InStock', 'http://schema.org/OutOfStock');
        ?>
" />
								</button>
				            </form>
						</div>
					<?php 
    }
    ?>
				</section>
			<?php 
}
?>
		</div>

		<?php 
Exemplo n.º 3
0
                                <input type="hidden" name="id" value="<?php 
        echo $item->id;
        ?>
">
                                <?php 
        foreach (page($item->uri)->variants()->toStructure() as $variant) {
            if (str::slug($variant->name()) === $item->variant) {
                // Get combined quantity of this option's siblings
                $siblingsQty = 0;
                foreach ($cart->data as $key => $qty) {
                    if (strpos($key, $item->uri . '::' . $item->variant) === 0 and $key != $item->id) {
                        $siblingsQty += $qty;
                    }
                }
                // Determine if we are at the maximum quantity
                if (inStock($variant) !== true and inStock($variant) <= $item->quantity + $siblingsQty) {
                    $maxQty = true;
                } else {
                    $maxQty = false;
                }
            }
        }
        ?>
                                <button class="uk-button uk-button-small" <?php 
        ecco($maxQty, 'disabled');
        ?>
 type="submit">&#9650;</button>
                            </form>
                        </td>
                        <td class="uk-text-right">
                            <?php 
Exemplo n.º 4
0
"><?php 
                echo str::ucfirst($option);
                ?>
</option>
                                        <?php 
            }
            ?>
                                    </select>
                                <?php 
        }
        ?>

                            </div>

                            <?php 
        if (inStock($variant)) {
            ?>
                                <button class="btn btn--accent" type="submit" property="offers" typeof="Offer">
                                    <?php 
            echo l::get('buy');
            ?>
                                    <link property="availability" href="http://schema.org/InStock" />
                                </button>
                            <?php 
        } else {
            ?>
                                <button class="btn btn--accent" type="submit" property="offers" typeof="Offer">
                                    <?php 
            echo l::get('out-of-stock');
            ?>
                                    <link property="availability" href="http://schema.org/OutOfStock" />
Exemplo n.º 5
0
                echo str::slug($option);
                ?>
"><?php 
                echo str::ucfirst($option);
                ?>
</option>
								<?php 
            }
            ?>
							</select>
						<?php 
        }
        ?>

						<?php 
        if (inStock($featuredVariant)) {
            ?>
							<button class="uk-margin-small-top uk-button uk-width-1-1 uk-button-primary" type="submit"><?php 
            echo l::get('buy');
            ?>
 <?php 
            echo formatPrice($featuredPrice);
            ?>
</button>
						<?php 
        } else {
            ?>
							<button class="uk-margin-small-top uk-button uk-width-1-1" disabled><?php 
            echo l::get('out-of-stock');
            ?>
 <?php