You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Functions relating to a Product in Jigoshop 1.6.5. Source can be found in `jigoshop_product.class.php`. If this is on Jigoshop documents, I managed not to find it.
This is a list of admin functions and which files they relate to
admin/jigoshop-admin-settings-api.php
class Jigoshop_Admin_Settings
__construct
Instantiates a Jigoshop_Options_Parser, and gets options, and parses it.
settings_scripts
Adds the scripts used to handle stuff (select2, bootstrap-tooltip, tools)
settings_styles
Adds the CSS
register_settings
Adds settings_sections, and creates settings
create_setting
Wrapper around add_settings_field
display_option( $option )
Wrapper around format_option_for_display option
display_section( $section )
Displays the section descriptions
output_markup
Handles the Jigoshop -> Settings page parsing.
build_tab_menu_items
The tab naviagtion on Jigoshop -> Settings page
get_current_tab_slug
Returns the page we're currently on on the tabbed options bits. Has get data: &tab=
get_current_tab_name
Returns the tab name.
validate_setting
Provides sanity checks for different user inputs so the options thing won't be corrupted.
remove_update_options
Remove all jigoshop_update_options actions on shipping and payment classes when not on those tabs
csort_tax_rates( $a, $b )
Used in a usort().
Defines a custom sort for the tax_rates array. The sort that is needed is that the array is sorted by country, followed by state, followed by compound tax. The difference is that compound must be sorted based on compound = no before compound = yes. Ultimately, the purpose of the sort is to make sure that country, state are all consecutive in the array, and that within those groups, compound = 'yes' always appears last. This is so that tax classes that are compounded will be executed last in comparison to those that aren't.
get_updated_tax_classes
When Options are saved, return the 'jigoshop_tax_rates' option values
class Jigoshop_Options_Parser
parse_options
Gets the available, and the actual, and sets up a current state variable.
format_option_for_display
Takes raw data, and depending on what the data is, parses it into pretty strings that look good on the frontend.
array_find
A custom array search algorithm due to the non-standard nature of array elements.
Formats a nice table. Used in Jigoshop -> Settings -> Tax
admin/jigoshop-admin-attributes.php
jigoshop_attributes()
Handles the form POST data from edit_attribute, save_attribute, delete requests from edit_attribute and add_attribute pages. Interface between frontend and database.
jigoshop_edit_attribute()
Relates to the Jigoshop -> Attributes -> Edit Attribute (not the configure items).
Outputs the html and form to the page
jigoshop_add_attribute()
Relates to Jigoshop -> Attributes page.
jigoshop-admin-dashboard.php
This whole section is related to Jigoshop -> Dashboard
class jigoshop_dashboard
__construct
Sets current page, enqueues scripts, and displays html
on_load_page
Scripts and styles are placed here, __construct calls it.
on_show_page
The actual html parsing
jigoshop_dash_right_now
Handles the "Right now" box on the dashboard
jigoshop_dash_recent_orders
Handles the recent orders bit.
jigoshop_dash_stock_report
Handles the stock report box
jigoshop_dash_recent_reviews
Handles the recent reviews box
jigoshop_dash_latest_news
Handles the latest news box.
jigoshop_dash_useful_links
Handles the useful links box
jigoshop_dash_monthly_report
Handles the monthy report box
jigoshop-admin-post-types
Functions used for custom post types in admin
These functions control columns in admin, and other admin interface bits
jigoshop_product_updated_message
Not needed now
jigoshop_edit_product_columns
Na
jigoshop_custom_product_columns
jigoshop_custom_product_sort
jigoshop_custom_product_orderby
jigoshop_products_by_category
jigoshop_filter_products_type
jigoshop_edit_order_columns
my_action_row
jigoshop_custom_order_columns
jigoshop_admin_product_search
jigoshop_admin_product_search_label
jigoshop_custom_order_views
jigoshop_remove_row_actions
jigoshop_bulk_actions
jigoshop_media_upload_downloadable_product
jigoshop_post_updated_messages
jigoshop_edit_coupon_columns
jigoshop_custom_coupon_columns
admin/jigoshop-admin-product-quick-bulk-edit.php
Functions used for Product Stock and Price editing using WordPress Bulk and Quick Edit
jigoshop_enqueue_product_quick_scripts
jigoshop_ajax_get_product_stock_price
jigoshop_add_to_bulk_quick_edit_custom_box
jigoshop_save_quick_edit
jigoshop_save_bulk_edit
admin/jigoshop-admin-reports.php
Functions used for displaying the jigoshop reports
------- Missing, need to do later -------
admin/jigoshop-admin-settings-options.php
$jigoshop_options_settings variable contains all the options used on the Jigoshop settings page
admin/jigoshop-admin-settings.php
Functions for the settings page in admin.
The settings page contains options for the Jigoshop plugin - this file contains functions to display and save the list of options.
---- will do it later -----
admin/jigoshop-admin-taxonomies.php
jigoshop_add_category_thumbnail_field
Used in Jigoshop -> Products -> Categories -> Add Category page. The thumbnail box towards the bottom on the left.
jigoshop_edit_category_thumbnail_field
Used in Jigoshop -> Products -> Categories -> Edit Category page. Responsible for all the layout and forms.
jigoshop_category_thumbnail_field_save
updates metadata related to the category in question.
jigoshop_product_cat_columns
Modifies the columns on the category page
jigoshop_product_cat_column
Modifies the individual column on the category page
Problem I have with Jigoshop is everything is wrapped in do_actions, which are a collection of stuff. But all I need is a title. Thankfully products in Jigoshop are merely a custom post type, so many of the things will be available through normal WordPress functions. Here's a bunch that could come in handy though.
To set up
Every time you loop through a product post type (which is product out of the box), you need to set up the product itself as well.
if( have_posts() ) {
while( have_posts() ) {
the_post();
$_product = new jigoshop_product( $post->ID );
// more code here
}
}
You will need to use $_product->function_name for all of them.
The functions
get_image( $size = 'shop_thumbnail' );
Returns, not echoes, an img tag with either a placeholder.png or the thumbnail of the product.
get_sku()
Returns, not echoes the sku of the product.
get_children()
Returns the children fo the product. Uses get_posts internally.
get_child( $child_ID )
Returns a new jigoshop_product or jigoshop_product_variation instance of the child. This could be either a variation of a product (say, a blue T-shirt instead of a red T-shirt), or if it's an actual hierarchical child, return that.
reduce_stock( $by = -1)
Calls modify_stock( -$by ) internally and returns what that returns.
Sidenote: Personally I would use modify_stock with a signed number to
keep us from using reduce_stock and increase_stock
increase_stock( $by = 1 )
Calls modify_stock( $by ) internally and returns what that returns. See sidenote above.
modify_stock( $by )
Returns if the product doesn't have a stock (because it's a virtual product for example). Internally it updates post_meta fields on the product post. Also handles "out of stock" logic by hiding products and producing alerts and whatnot.
Returns the new stock. (if you had 43 apples, modified stock by -5, will return 38)
requires_shipping()
Need to look into it
is_type( $type )
$type can be a string or an array. Check whether the current product is in the type we specified. Returns boolean.
has_child()
Returns boolean. Calls get_children() internally. See above.
exists()
Checks the exists property on the product object. Returns boolean.
is_taxable()
Checks tax_status property on the product object. Returns true if it equals to taxable.
is_shipping_taxable()
Checks is_taxable() on object or tax_status property. If tax_status equals shipping or is_taxable() is true, returns true.
get_post_data()
If the post property hasn't been populated, get's the WordPress post object by the same ID, sets it to the product object's post property, and returns the post.
Sidenote: You probably don't need to use this very often, as you will have access to the
$post object anyways. This might come in handy if you're displaying the children of a
product.
get_title()
Internally it uses get_post_data(), and then applies the filter jigoshop_product_title to the title (which is a WordPress standard get_the_title call).
add_to_cart_url()
Fairly complex bit, but returns an url that if you visit will add the product to the cart. Uses jigoshop::nonce_url for this.
managing_stock()
If the Jigoshop manage stock option is not yes, returns, otherwise returns the manage_stock property of the product as boolean.
is_in_stock( $below_stock_threshold = false)
If we're not managing stock, do nothing.
If there are children (variations), and either of them are in stock, return true.
Sidenote: checking if children are in stock is a recursive function. $child->is_in_stock() will
be called and repeated until a product doesn't have a child. Depth first, even! :)
If we're not managing stock, and the stock_status property is instock, returns true.
If we're managing stock, and backorders are allowed, returns true.
If we're managing stock, and we're checking for threshold: if below the stock threshold or if we're not checking for threshold, is the stock more than 0, return 0.
In every other case return false.
backorders_allowed()
Checks the backorders property on this object (to be yes), or whether this has a backorders_require_notification, which is a wrapper around checking whether the backorders property equals notify.
Sidenote: This whole thing could have been written in one line:
`return (in_array($this->backorders, array('yes', 'notify'));
Although checking for notify is probably used somewhere else
has_enough_stock( $quantity )
Spawns a new product with the same ID, and checks whether either backorders are allowed, or the stock is higher than how much we want to check against.
get_stock()
Returns the value of the stock property on the object.
get_availability()
Basically returns a string based on settings (backordering, managins stock, etc) and available stock which is going to be one of the following
Out of Stock
Available on Backorder
In Stock
is_featured()
Returns a boolean. Property featured on the object. You can control this via the jigoshop product options page.
is_visible()
Returns boolean based on what the visibility property is.
If hidden, returns false
If search, returns same as WordPress' is_search()
If catalog, returns opposite of WordPress' is_search()
Any other, returns true
is_on_sale()
Checks properties sale_price_dates_from and sale_price_dates_to against current timestamp, and checks whether there's a sale_price set. Returns boolean.
get_weight()
Returns the object's weight property.
get_price_excluding_tax( $quantity = 1 )
Returns the price of $quantity items ex tax.
get_price_with_tax( $quantity = 1 )
Returns the price of $quantity items with tax.
get_tax_base_rate()
Returns an array with the tax rates in it. Different from the destination rate is that it uses
$my_rate = $_tax->get_shop_base_rate($tax_class)
get_tax_destination_rate
Returns an array with the destination taxes in it. Difference from base rate is this line:
$my_rate = $_tax->get_rate($tax_class)
When passed $tax_class and $product_tax_rates, and the first is true, and the second is true, and the second is an array, it will return $product_tax_rates[$tax_class]['rate'], otherwise 0;
Same as above, but returns $product_tax_rates[$tax_class]['is_not_compound_tax'] (could be either true or false), or true by default.
get_percentage_sale()
Returns the sale percentage (sale price / normal price) rounded with % appended at the end.
get_regular_price()
Returns the regular_price property on the object.
get_price()
Returns the actual price of the product. If it's on sale, the sale price, otherwise the normal price. But without taxes applied.
adjust_price( $new_price )
If the product is on sale, get_price()+$new_price is going to be sale_price on the product. Otherwise regular_price += $new_price. Does not return anything. This is maybe used by coupons?
get_calculated_sale_price_html()
Fancy markup involving <del> and <ins> to output --£30--£23
get_price_html()
Returns one of these based on settings:
<span class="from"> From price </span>
Price not announced
Free
get_upsells()
Returns the upsell_ids meta on the product or an empty array.
get_cross_sells()
Returns the crossell_ids meta on the product or an empty array.
Returns by default a comma separated list of terms the product belongs to in the product_cat taxonomy.
get_tags($sep=', ', $before='', $after='')
Returns by default a comma separated list of terms the product belongs to in the product_tag taxonomy.
get_rating_html($location='')
Returns an html tag with the star rating bit based on the rating meta on the comments.
get_related()
Returns all other products that have the same category or tag. Uses get_posts() internally.
get_attribute( $key )
Gets all the attributes first using get_attributes(), and then returns the value from that array that the $key specifies. If the $attr is a taxonomy, it returns the terms of that taxonomy.
get_attributes()
If the attributes property isn't set, check if there's a product_attributes key in the meta property array on the product. Return them.
has_attributes()
Gets all the attributes, and based on whether that's empty, or not visible, returns true or false.
has_dimensions($all_dimensions = false)
If $all_dimensions is false, returns true if either of the dimensions are defined (length, width, height), otherwise if $all_dimensions is true, returns true if all dimensions are defined.
has_weight()
Returns the same as get_weight() if we enabled weight.
list_attributes()
Returns an html table with visible attributes in there.
get_available_attribues_variations()
A glorified loop, basically returns an array with all attributes (which are custom taxonomies) and all terms in those attributes in an array.
get_default_attributes()
Returns the _default_attributes keyed value in the meta property array on the object if exists, otherwise empty string.
getAttributeTaxonomies()
Returns everything in the jigoshop_attribute_taxonomies table as per standard $wpdb->get_results() functionality.
attribute_label( $name )
If in name we have pa_, selects the attribute_label column from the jigoshop_attribute_taxonomies table where attribute_name equals to pa_$name. If that is successfull, return the label, otherwise return the ucfirst of name.