Skip to content

Instantly share code, notes, and snippets.

View zainaali's full-sized avatar

Zain Ali zainaali

  • Lahore Punjab, Pakistan
View GitHub Profile
@zainaali
zainaali / functions.php
Created September 28, 2018 04:36 — forked from musamamasood/functions.php
Method to set order status failed or completed based on Stripe 3D.
add_action( 'wc_gateway_stripe_process_response', 'prefix_wc_gateway_stripe_process_response', 20, 2 );
function prefix_wc_gateway_stripe_process_response( $response, $order ){
if($response->source->type == 'three_d_secure'){
$order->update_status('completed', 'order_note'); ####
//WC_Stripe_Logger::log( 'wc_gateway_stripe_process_response three_d_secure response: ' . print_r( $response->source->type, true ) );
}elseif($response->source->type == 'card'){
$order->update_status('failed', 'order_note'); ####
//WC_Stripe_Logger::log( 'wc_gateway_stripe_process_response card response: ' . print_r( $response->source->type, true ) );
}
}
@zainaali
zainaali / functions.php
Created September 28, 2018 04:35 — forked from musamamasood/functions.php
Shortcode to fetch post by post_type
// create shortcode to list all clothes which come in blue
function statesmen_news_shortcode( $atts ) {
$html = '';
// Attributes
$atts = shortcode_atts(
array(
'post_per_page' => '2',
'post_type' => 'post',
'id' => false
),
@zainaali
zainaali / comments.php
Created September 27, 2018 10:33
Add class and placeholder to name and email field of Wordpress comment template
$fields = array(
'author' => '<ul class="row"><li class="col-sm-6"><label>' . '<input class="form-control" id="author" name="author" type="text" placeholder="' . esc_attr__( "Name", "text-domain" ) . '" value="' . esc_attr( $commenter['comment_author'] ) . '" size=""' . $aria_req . ' /></label></li>',
'email' => '<li class="col-sm-6"><label>' . '<input class="form-control" name="email" type="text" placeholder="' . esc_attr__( "Email", "text-domain" ) . '" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size=""' . $aria_req . ' /></label></li>',
);
comment_form(array('fields'=>$fields));
@zainaali
zainaali / functions.php
Created September 27, 2018 10:30
Customize message field of comment form wordpress
function glowlogix_comment_field($comment_field){
$comment_field =
'<li class="col-sm-12">
<textarea required placeholder="MESSAGE" class="form-control" name="comment" aria-required="true"></textarea>
</li>';
return $comment_field;
}
add_filter('comment_form_field_comment', 'glowlogix_comment_field');
@zainaali
zainaali / functions.php
Created September 27, 2018 10:29
Create post comment button and remove default post comment button
// create post comment button
function glowlogix_comment_button() {
echo '<input name="submit" type="submit" class="btn margin-top-20" value="Send">';
}
add_action( 'comment_form', 'glowlogix_comment_button' );
For remove default button add "display: none" property in your style.css file
@zainaali
zainaali / functions.php
Created September 27, 2018 10:26
Function for customize default design of comment template
//Function for customize default design of comment template
function glowlogix_comment($comment, $args, $depth) {
if ( 'div' === $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
@zainaali
zainaali / functions.php
Created September 22, 2018 11:32
Create Custom Billing Field and pre fill Auto fill checkout default filed and custom filed from user data saved in Woocommerce session
/**
* C.1. Custom Billing Field
*/
add_filter( 'woocommerce_billing_fields' , 'wc_custom_fields' );
function wc_custom_fields( $fields ) {
$fields['billing_reservationcode'] = array(
'type' => 'text',
'required' => true,
'class' => array('reservationcode'),
@zainaali
zainaali / functions.php
Last active April 15, 2019 18:47
WooCommerce: Allow adding multiple products and set price to the cart via the add-to-cart query string
application/x-httpd-php functions.php ( PHP script, ASCII text )
<?php
/**
*
* 1. Bond Only - Expedia, Direct, HomeAway
* https://readysethost.co/checkout/?add-to-cart=772:1:2.00&rcode=TST2&fname=Mike&lname=Aubor&email=damiike%40gmail.com
* 2. Booking Only - Booking.com, Direct, HomeAway
* https://readysethost.co/checkout/?add-to-cart=1334:1:1.00&rcode=TST2&fname=Mike&lname=Aubor&email=damiike%40gmail.com
* 3. Booking Deposit Only - Direct, HomeAway
@zainaali
zainaali / scroll.js
Created February 22, 2018 20:48
Make scrolling sidebar along with page and stop at footer
(function($) {
//id of sidebar
var element = $('#sidebar')
originalY = $(element).offset().top;
// Space between element and top of screen (when scrolling)
var topMargin = 20;
// Should probably be set in CSS; but here just for emphasis
element.css('position', 'relative');
$(window).on('scroll', function(event) {
@zainaali
zainaali / scroll.js
Last active February 22, 2018 21:07
Make sidebar scroll able along with page and stop at footer
(function($) {
//id of sidebar
var element = $('#sidebar')
originalY = $(element).offset().top;
// Space between element and top of screen (when scrolling)
var topMargin = 20;
// Should probably be set in CSS; but here just for emphasis
element.css('position', 'relative');
$(window).on('scroll', function(event) {