Skip to content

Instantly share code, notes, and snippets.

@wpweb101
wpweb101 / add-voucher-vendor-role.php
Created August 24, 2015 05:30
Add any role as a voucher vendor role.
<?php
function woo_vou_add_role_as_voucher_vendor( $roles = array() ) {
$roles[] = 'wc_vendor';
return $roles;
}
add_filter( 'woo_vou_edit_vendor_role', 'woo_vou_add_role_as_voucher_vendor' );
@wpweb101
wpweb101 / woo-vou-unlimited-code-params.php
Last active April 24, 2024 10:53
Woocommerce PDF Vouchers - Modify Unlimited voucher codes pattern logic
<?php
// You can modify / remove following fields using the filter
// buyername, code_prefix, order_id, data_id, $item_id
// $voucher_codes = array( 'buyername' => $buyername, 'code_prefix' => $code_prefix, 'order_id' => $order_id, 'data_id' => $data_id, 'item_id' => $item_id, 'separator' => '-' );
function woo_vou_unlimited_code_pattern_modification( $voucodes_args = array() ) {
if( $voucodes_args['buyername'] ) {// if you want to remove buyername from pattern
unset( $voucodes_args['buyername'] );
}
@wpweb101
wpweb101 / woo-vou-modify-pdf.php
Created September 28, 2015 12:29
woocommerce pdf voucher - Modify PDF size and Font
<?php
// For Modify Existing PDF size and font size
function woo_vou_modify_existing_pdf_sizes( $pdf_sizes = array() ) {
//modify a4 pdf width
$pdf_sizes['A4']['width'] = 500;
//modify a4 pdf height
$pdf_sizes['A4']['height'] = 500;
//modify a4 pdf font size
@wpweb101
wpweb101 / woo-vou-pdf-generate-fonts.php
Last active December 18, 2024 13:26
Woocommerce PDF Vouchers - Change PDF Font
<?php
function woo_vou_pdf_modify_generate_fonts( $pdf_font ) {
// by default the font type is "helvetica"
$pdf_font = 'freeserif';
return $pdf_font;
}
add_filter( 'woo_vou_pdf_generate_fonts', 'woo_vou_pdf_modify_generate_fonts' );
@wpweb101
wpweb101 / wpw-auto-poster-checked-publishbox.php
Last active January 26, 2018 07:25
Social Auto Poster - To remain `Publish Post On` checkbox ticked
<?php
function wpw_auto_poster_checked_social_publishbox( $publish_arr ) {
// Social network title for which you want to remain ticked the 'Publish Post On' checked box
$publish_arr = array(
'facebook',
'twitter',
'linkedin',
'tumblr',
@wpweb101
wpweb101 / woocl-non-loggedin-login-redirect.php
Created November 16, 2015 09:23
Woocommerce Collections - Change Redirect URL for non loggedin user
<?php
function woo_cl_redirect_to_my_account( $redirect_url = '' ) {
// my account page URL
$redirect_url = get_permalink( get_option('woocommerce_myaccount_page_id') );
return $redirect_url;
}
add_filter( 'woo_cl_redirect_link_for_non_login_user', 'woo_cl_redirect_to_my_account' );
@wpweb101
wpweb101 / woo-vou-custom-field-in-download-pdf.php
Last active March 16, 2016 11:58
Add custom shortcode in download PDF
<?php
/**
* Adding Custom shortcode value in PDF voucher
*/
function woo_vou_pdf_template_replace_shortcodes( $voucher_template_html, $orderid, $item_key, $items, $voucodes, $productid ) {
// replace {your_shortcode} with actual value
$voucher_template_html = str_replace( '{your_shortcode}', $your_shortcode_value, $voucher_template_html );
return $voucher_template_html;
@wpweb101
wpweb101 / edd-points-restrict-seller.php
Created December 8, 2015 11:32
Edd Points and Rewards - Restrict Seller
<?php
/**
* Function to allow sellers to get points even if they are the owner of the product
*
* @param array $roles
* @return $roles
*/
function edd_points_restrict_seller_roles( $roles ) {
$roles[] = 'administrator';
@wpweb101
wpweb101 / woo-vou-admin-voucher-code-tabs.php
Last active December 21, 2015 08:05
Add / Remove tabs for voucher codes listing at wp admin side
<?php
/**
*
* You can add or remove tab using this filter
*/
add_filter( 'woo_vou_admin_voucher_code_tabs', 'woo_vou_admin_voucher_code_custom_tabs' );
function woo_vou_admin_voucher_code_custom_tabs( $voucher_code_tabs ) {
@wpweb101
wpweb101 / disable-auto-enable-downloadable-variation.php
Last active March 8, 2016 11:50
Disable Auto Enable Variations As Downloadable
<?php
function disable_auto_enable_variations_download( $auto_enable ) {
$auto_enable = false;
return $auto_enable;
}
add_filter( 'woo_vou_auto_enable_downloadable_variations', 'disable_auto_enable_variations_download' )