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
function authentication_redirect () { | |
if( !is_user_logged_in() ) { | |
$login_page_url = get_permalink( get_page_by_path( 'log' ) ); | |
wp_safe_redirect($login_page_url); | |
} | |
} |
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
add_action( 'init', 'woocommerce_clear_cart_url' ); | |
function woocommerce_clear_cart_url() { | |
global $woocommerce; | |
if ( isset( $_GET['empty-cart'] ) ) { | |
$woocommerce->cart->empty_cart(); | |
} | |
} |
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
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); | |
function custom_override_checkout_fields( $fields ) { | |
$fields['billing']['billing_city']['label'] = 'City'; | |
$fields['billing']['billing_phone']['required'] = false; | |
$fields['order']['order_comments']['placeholder'] = 'My new placeholder'; | |
//removing fields | |
unset($fields['order']['order_comments']); | |
//adding custom fields | |
$fields['shipping']['shipping_phone'] = array( | |
'label' => __('Phone', 'woocommerce'), |
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
add_filter( 'default_checkout_country', 'change_default_checkout_country' ); | |
function change_default_checkout_country() { | |
return 'US'; // country code | |
} |
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
function custom_add_to_cart_archieve($post_id_as_product) { | |
global $woocommerce; | |
$product_factory_custom = new WC_Product_Factory(); | |
$product_object_by_id = $product_factory_custom->get_product($post_id_as_product); | |
// var_dump($product_object_by_id); | |
if ( ! $product_object_by_id->is_purchasable() ) return; | |
?> | |
<?php | |
// Availability |
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
/** | |
* Change the add to cart text on product archives | |
*/ | |
add_filter( 'add_to_cart_text', 'woo_archive_custom_cart_button_text' ); | |
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_archive_custom_cart_button_text' ); | |
function woo_archive_custom_cart_button_text() { | |
global $woocommerce; | |
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
$( "#dateID" ).datepicker({ | |
dateFormat: 'D M d', | |
onSelect: function(dateText, inst) { | |
var dateArr = dateText.split(' ') | |
var suffix = ""; | |
switch(inst.selectedDay) { | |
case '1': case '21': case '31': suffix = 'st'; break; | |
case '2': case '22': suffix = 'nd'; break; | |
case '3': case '23': suffix = 'rd'; break; | |
default: suffix = 'th'; |
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
$('table').DataTable( { | |
dom: 'T<"clear">lfrtip', | |
tableTools: { | |
"sSwfPath": "../swf/copy_csv_xls_pdf.swf", //path to your swf folder | |
"aButtons": [ | |
{ | |
"sExtends": "pdf", | |
"sPdfOrientation": "landscape", | |
"sPdfMessage": "Attendence Report For <?php echo get_the_title($event_id_url);?>", | |
"sButtonText": "Export to PSD" |
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 function array2csv(array &$array) | |
{ | |
if (count($array) == 0) { | |
return null; | |
} | |
ob_start(); | |
$df = fopen("php://output", 'w'); | |
fputcsv($df, array_keys(reset($array))); | |
foreach ($array as $row) { | |
fputcsv($df, $row); |
OlderNewer