This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Insert custom css/javascript from custom fields named custom_js and custom_css | |
* into a blog post or a page | |
* from http://blue-anvil.com/archives/including-css-javascript-in-wordpress-posts-using-custom-fields/ | |
*/ | |
function sv_add_post_custom_scripts() { | |
if ( ! is_singular() ) { | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WooCommerce Memberships: "Welcome" section | |
* Custom template added to the "Member Area" | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
/** | |
* Renders the welcome section for the membership in the my account area. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Modify membership product pricing display for non-members | |
* changes pricing display if purchasing is restricted to members; | |
* active members will see the price instead of a message | |
* | |
* @param string $price the WC price HTML | |
* @return string $price the updated price HTML | |
*/ | |
function sv_change_member_product_price_display( $price ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds item costs from Cost of Goods to Order XML Export | |
* | |
* @param array $items the data included per line item | |
* @param \WC_Order $order the order object | |
* @param array $item line item data from the order | |
* @return array the updated line item xml data | |
*/ | |
function sv_add_cost_to_xml_export_items( $items, $order, $item ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds a registration prompt to the WC thank you page | |
* Only added for guest purchases | |
* | |
* @param int $order_id the ID of the order just placed | |
*/ | |
function sv_thankyou_registration_prompt( $order_id ) { | |
$my_account_url = get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// get the email param if it's set so the registration form can use it | |
function sv_get_account_email_param() { | |
$_POST['email'] = isset( $_GET['email'] ) ? urldecode( $_GET['email'] ) : false; | |
} | |
add_action( 'woocommerce_register_form_start', 'sv_get_account_email_param' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds a "Create an account?" section to customer emails | |
* Only added for emails sent to guest purchases | |
* | |
* @param \WC_Order $order the order object | |
* @param bool $sent_to_admin false if emails are sent to customers | |
* @param bool $plain_text false for HTML emails | |
*/ | |
function sv_add_email_register_section( $order, $sent_to_admin, $plain_text ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Only copy opening php if needed | |
// Removes the product short description / excerpt column from "My Products" | |
function sv_members_area_products_table_columns( $columns ) { | |
if ( isset( $columns['membership-product-excerpt'] ) ) { | |
unset( $columns['membership-product-excerpt'] ); | |
} | |
return $columns; | |
} | |
add_filter('wc_memberships_members_area_my_membership_products_column_names', 'sv_members_area_products_table_columns', 10, 1 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// only copy the opening php tag if needed | |
// Change the shop / product prices if a unit_price is set | |
function sv_change_product_html( $price_html, $product ) { | |
$unit_price = get_post_meta( $product->id, 'unit_price', true ); | |
if ( ! empty( $unit_price ) ) { | |
$price_html = '<span class="amount">' . wc_price( $unit_price ) . ' per kg</span>'; | |
} |