/** * Displays field according to definition. * * @param array $field Field parameters. * * @return string Field output to display. */ public function displayField(array $field) { switch ($field['type']) { case 'user_defined': // Workaround for PHP pre-5.4 echo call_user_func($field['display'], $field); break; case 'text': Forms::text($field); break; case 'number': Forms::number($field); break; case 'select': Forms::select($field); break; case 'checkbox': Forms::checkbox($field); break; case 'constant': Forms::constant($field); break; case 'textarea': Forms::textarea($field); break; default: $this->wp->doAction('jigoshop\\admin\\settings\\form_field\\' . $field['type'], $field); } }
?> </fieldset> <fieldset> <?php Forms::daterange(array('id' => 'coupon_date', 'name' => array('from' => 'jigoshop_coupon[from]', 'to' => 'jigoshop_coupon[to]'), 'label' => __('Coupon date', 'jigoshop'), 'tip' => __('Choose between which dates this coupon is enabled. Leave empty for any date.', 'jigoshop'), 'placeholder' => __('Any date', 'jigoshop'), 'value' => array('from' => $coupon->getFrom() ? $coupon->getFrom()->format('m/d/Y') : '', 'to' => $coupon->getTo() ? $coupon->getTo()->format('m/d/Y') : ''))); ?> </fieldset> <fieldset> <?php Forms::text(array('name' => 'jigoshop_coupon[usage_limit]', 'label' => __('Usage limit', 'jigoshop'), 'type' => 'number', 'description' => sprintf(__('Times used: %s', 'jigoshop'), $coupon->getUsage()), 'tip' => __('Control how many times this coupon may be used.', 'jigoshop'), 'placeholder' => 0, 'value' => $coupon->getUsageLimit())); ?> <?php Forms::checkbox(array('name' => 'jigoshop_coupon[individual_use]', 'label' => __('Individual use', 'jigoshop'), 'description' => __('Prevent other coupons from being used while this one is applied to the Cart.', 'jigoshop'), 'checked' => $coupon->isIndividualUse())); ?> <?php Forms::checkbox(array('name' => 'jigoshop_coupon[free_shipping]', 'label' => __('Free shipping', 'jigoshop'), 'description' => __('Show the Free Shipping method on the Checkout with this enabled.', 'jigoshop'), 'checked' => $coupon->isFreeShipping())); ?> </fieldset> <fieldset> <?php Forms::text(array('name' => 'jigoshop_coupon[order_total_minimum]', 'label' => __('Order total minimum', 'jigoshop'), 'type' => 'number', 'description' => __('Set the required minimum subtotal for this coupon to be valid on an order.', 'jigoshop'), 'placeholder' => __('No minimum', 'jigoshop'), 'value' => $coupon->getOrderTotalMinimum())); ?> <?php Forms::text(array('name' => 'jigoshop_coupon[order_total_maximum]', 'label' => __('Order total maximum', 'jigoshop'), 'type' => 'number', 'description' => __('Set the required maximum subtotal for this coupon to be valid on an order.', 'jigoshop'), 'placeholder' => __('No maximum', 'jigoshop'), 'value' => $coupon->getOrderTotalMaximum())); ?> </fieldset> <fieldset> <?php Forms::text(array('name' => 'jigoshop_coupon[products]', 'label' => __('Include products', 'jigoshop'), 'description' => __('Control which products this coupon can apply to. If this is left blank it will have effect on all of the products.', 'jigoshop'), 'value' => join(',', $coupon->getProducts()))); ?> <?php
*/ ?> <tr> <td> <?php Forms::text(array('id' => 'tax_rule_label_' . $rule['id'], 'name' => Options::NAME . '[rules][label][' . $rule['id'] . ']', 'value' => $rule['label'], 'placeholder' => __('Rule label', 'jigoshop'))); ?> </td> <td> <?php Forms::select(array('id' => 'tax_rule_class_' . $rule['id'], 'name' => Options::NAME . '[rules][class][' . $rule['id'] . ']', 'value' => $rule['class'], 'options' => $classes, 'placeholder' => __('Tax class', 'jigoshop'))); ?> </td> <td> <?php Forms::checkbox(array('id' => 'tax_rule_compound_' . $rule['id'], 'name' => Options::NAME . '[rules][compound][' . $rule['id'] . ']', 'checked' => $rule['is_compound'])); ?> </td> <td> <?php Forms::text(array('id' => 'tax_rule_rate_' . $rule['id'], 'name' => Options::NAME . '[rules][rate][' . $rule['id'] . ']', 'value' => $rule['rate'], 'placeholder' => __('Tax rate', 'jigoshop'))); ?> </td> <td> <?php Forms::select(array('id' => 'tax_rule_country_' . $rule['id'], 'name' => Options::NAME . '[rules][country][' . $rule['id'] . ']', 'classes' => array('tax-rule-country'), 'value' => $rule['country'], 'options' => $countries)); ?> </td> <td> <?php Forms::text(array('id' => 'tax_rule_states_' . $rule['id'], 'name' => Options::NAME . '[rules][states][' . $rule['id'] . ']', 'classes' => array('tax-rule-states'), 'placeholder' => _x('Write the state', 'admin_taxing', 'jigoshop'), 'value' => is_array($rule['states']) ? join(',', $rule['states']) : $rule['states']));
$to = time(); if ($product instanceof Product\Saleable) { /** @var Product\Saleable $product */ $enabled = $product->getSales()->isEnabled(); $price = $product->getSales()->getPrice(); if ($product->getSales()->getFrom()->getTimestamp() < time() && $product->getSales()->getTo()->getTimestamp() < time()) { $product->getSales()->getFrom()->setTimestamp(time()); $product->getSales()->getTo()->setTimestamp(time()); } $from = $product->getSales()->getFrom()->format('m/d/Y'); $to = $product->getSales()->getTo()->format('m/d/Y'); } ?> <fieldset> <?php Forms::checkbox(array('name' => 'product[sales_enabled]', 'id' => 'sales-enabled', 'label' => __('Put product on sale?', 'jigoshop'), 'checked' => $enabled)); ?> </fieldset> <fieldset class="schedule" style="<?php !$enabled and print 'display: none;'; ?> "> <h3><?php _e('Schedule', 'jigoshop'); ?> </h3> <?php Forms::text(array('name' => 'product[sales_price]', 'label' => __('Sale price', 'jigoshop'), 'value' => $price, 'placeholder' => __('15% or 19.99', 'jigoshop'))); Forms::daterange(array('id' => 'product_sales_date', 'name' => array('from' => 'product[sales_from]', 'to' => 'product[sales_to]'), 'id' => 'sales-range', 'label' => __('Sale date', 'jigoshop'), 'value' => array('from' => $from, 'to' => $to))); ?> </fieldset>
<?php use Jigoshop\Admin\Helper\Forms; use Jigoshop\Entity\Product; /** * @var $product Product The product. * @var $taxClasses array Available tax classes. */ ?> <fieldset> <?php Forms::checkbox(array('name' => 'product[is_taxable]', 'id' => 'is_taxable', 'label' => __('Is taxable?', 'jigoshop'), 'checked' => $product->isTaxable())); Forms::select(array('name' => 'product[tax_classes]', 'id' => 'tax_classes', 'label' => __('Tax classes', 'jigoshop'), 'multiple' => true, 'value' => $product->getTaxClasses(), 'options' => $taxClasses, 'classes' => array($product->isTaxable() ? '' : 'not-active'))); ?> </fieldset> <?php do_action('jigoshop\\product\\tabs\\advanced', $product);
</div> <div class="col-md-7 values"> <h5><?php _e('Values', 'jigoshop'); ?> </h5> <?php switch ($attribute->getType()) { case Attribute\Multiselect::TYPE: ?> <?php foreach ($attribute->getOptions() as $option) { /** @var $option Attribute\Option */ ?> <?php Forms::checkbox(array('name' => 'product[attributes][' . $attribute->getId() . '][options]', 'id' => 'product_attributes_' . $attribute->getId() . '_option_' . $option->getId(), 'classes' => array('attribute-' . $attribute->getId()), 'label' => $option->getLabel(), 'value' => apply_filters('jigoshop\\template\\admin\\product\\attribute\\multiselect\\value', $option->getId(), $attribute, $option), 'multiple' => true, 'checked' => in_array($option->getId(), $attribute->getValue()))); ?> <?php } ?> <?php break; case Attribute\Select::TYPE: ?> <div class="panel-body"><?php Forms::select(array('name' => 'product[attributes][' . $attribute->getId() . ']', 'classes' => array('attribute-' . $attribute->getId()), 'value' => apply_filters('jigoshop\\template\\admin\\product\\attribute\\select\\value', $attribute->getValue(), $attribute), 'options' => Product::getSelectOption($attribute->getOptions()), 'size' => 12)); ?> </div><?php break; case Attribute\Text::TYPE: ?>
<?php use Jigoshop\Admin\Helper\Forms; use Jigoshop\Entity\Product; use Jigoshop\Entity\Product\Attributes\StockStatus; /** * @var $product Product The product. */ $stock = $product instanceof Product\Purchasable ? $product->getStock() : new StockStatus(); ?> <fieldset> <?php Forms::checkbox(array('name' => 'product[stock_manage]', 'id' => 'stock-manage', 'label' => __('Manage stock?', 'jigoshop'), 'checked' => $stock->getManage())); Forms::select(array('name' => 'product[stock_status]', 'id' => 'stock-status', 'label' => __('Status', 'jigoshop'), 'value' => $stock->getStatus(), 'options' => array(StockStatus::IN_STOCK => __('In stock', 'jigoshop'), StockStatus::OUT_STOCK => __('Out of stock', 'jigoshop')), 'classes' => array($stock->getManage() ? 'not-active' : ''))); ?> </fieldset> <fieldset class="stock-status" style="<?php !$stock->getManage() and print 'display: none;'; ?> "> <?php Forms::number(array('name' => 'product[stock_stock]', 'label' => __('Items in stock', 'jigoshop'), 'value' => $stock->getStock(), 'min' => 0)); ?> <?php Forms::select(array('name' => 'product[stock_allow_backorders]', 'label' => __('Allow backorders?', 'jigoshop'), 'value' => $stock->getAllowBackorders(), 'options' => array(StockStatus::BACKORDERS_FORBID => __('Do not allow', 'jigoshop'), StockStatus::BACKORDERS_NOTIFY => __('Allow, but notify customer', 'jigoshop'), StockStatus::BACKORDERS_ALLOW => __('Allow', 'jigoshop')))); ?> </fieldset> <?php do_action('jigoshop\\product\\tabs\\stock', $product);
/** * Adds variable options to attribute field. * * @param Attribute|Attribute\Variable $attribute Attribute. */ public function addVariableAttributeOptions(Attribute $attribute) { if ($attribute instanceof Attribute\Variable) { /** @var $attribute Attribute|Attribute\Variable */ Forms::checkbox(array('name' => 'product[attributes][' . $attribute->getId() . '][is_variable]', 'id' => 'product_attributes_' . $attribute->getId() . '_variable', 'classes' => array('attribute-options'), 'label' => __('Is for variations?', 'jigoshop'), 'checked' => $attribute->isVariable(), 'size' => 6)); } }
use Jigoshop\Helper\Currency; use Jigoshop\Helper\Product as ProductHelper; /** * @var $product Product The product. */ ?> <fieldset> <?php Forms::text(array('name' => 'product[regular_price]', 'label' => __('Price', 'jigoshop') . ' (' . Currency::symbol() . ')', 'placeholder' => __('Price not announced', 'jigoshop'), 'classes' => array('product-simple', $product instanceof Product\Purchasable ? '' : 'not-active'), 'value' => $product instanceof Product\Purchasable ? $product->getRegularPrice() : 0)); Forms::text(array('name' => 'product[sku]', 'label' => __('SKU', 'jigoshop'), 'value' => $product->getSku(), 'placeholder' => $product->getId())); Forms::text(array('name' => 'product[brand]', 'label' => __('Brand', 'jigoshop'), 'value' => $product->getBrand())); Forms::text(array('name' => 'product[gtin]', 'label' => __('GTIN', 'jigoshop'), 'tip' => 'Global Trade Item Number', 'value' => $product->getGtin())); Forms::text(array('name' => 'product[mpn]', 'label' => __('MPN', 'jigoshop'), 'tip' => 'Manufacturer Part Number', 'value' => $product->getMpn())); ?> </fieldset> <fieldset> <?php Forms::text(array('name' => 'product[size_weight]', 'label' => __('Weight', 'jigoshop') . ' (' . ProductHelper::weightUnit() . ')', 'value' => $product->getSize()->getWeight())); Forms::text(array('name' => 'product[size_length]', 'label' => __('Length', 'jigoshop') . ' (' . ProductHelper::dimensionsUnit() . ')', 'value' => $product->getSize()->getLength())); Forms::text(array('name' => 'product[size_width]', 'label' => __('Width', 'jigoshop') . ' (' . ProductHelper::dimensionsUnit() . ')', 'value' => $product->getSize()->getWidth())); Forms::text(array('name' => 'product[size_height]', 'label' => __('Height', 'jigoshop') . ' (' . ProductHelper::dimensionsUnit() . ')', 'value' => $product->getSize()->getHeight())); ?> </fieldset> <fieldset> <?php Forms::select(array('name' => 'product[visibility]', 'label' => __('Visibility', 'jigoshop'), 'options' => array(Product::VISIBILITY_PUBLIC => __('Catalog & Search', 'jigoshop'), Product::VISIBILITY_CATALOG => __('Catalog Only', 'jigoshop'), Product::VISIBILITY_SEARCH => __('Search Only', 'jigoshop'), Product::VISIBILITY_NONE => __('Hidden', 'jigoshop')), 'value' => $product->getVisibility())); Forms::checkbox(array('name' => 'product[featured]', 'label' => __('Featured?', 'jigoshop'), 'checked' => $product->isFeatured(), 'description' => __('Enable this option to feature this product', 'jigoshop'))); ?> </fieldset> <?php do_action('jigoshop\\product\\tabs\\general', $product);