Friday 18 August 2017

Wordpress Hook Change the add to cart text on product archives

Here is the Wordpress Hook Change the add to cart text on product archives
add_filter( 'add_to_cart_text', 'woo_archive_custom_cart_button_text' );
function woo_archive_custom_cart_button_text() {
global $woocommerce;
foreach($woocommerce->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values['data'];
if( get_the_ID() == $_product->id ) {
return __('Already in cart', 'woocommerce');
}
}
return __('Add to cart', 'woocommerce');
}

WORDPRESS THEME: REDIRECT TO HOME PAGE ON LOGOUT

Here is the code for WORDPRESS THEME: REDIRECT TO HOME PAGE ON LOGOUT:


add_action('wp_logout', 'go_home');
function go_home(){wp_redirect(home_url());exit();}

In Laravel Check IN query that paramters has file or not

Here is the query for In Laravel Check IN query that parameters has file or not:

if ($request->hasFile('photo')) {
    //
}


Create New Column In Database tables In Laravel5.3 With Php

Here is the php artisan command for Create New Column In Database tables In Laravel5.3

php artisan make:migration add_Image_to_users
after it check the add_Image_to_users.php files in database migration folder and add below code
public function up()
{
    Schema::table('users', function($table) {
        $table->string('image');
    });
}
After it run below command:
php artisan migrate

Laravel 5.3 Upload Image With user Information

Here is the working code for Laravel 5.3 Upload Image With user Information, Today I have done this code after facing image upload problem with save Image name in database and I have solved it and I am sharing with you all.


public function store(Request $request)
{
$this->validate($request, [
'price' => 'numeric',
'width' => 'numeric',
'height' => 'numeric',
'depth' => 'numeric',
'parts_warranty' => 'numeric',
'labor_warranty' => 'numeric',
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:250|dimensions:max_width=250,max_height=250',
]);
/*Image Upload*/
$imageName = time().'.'.$request->image->getClientOriginalExtension();
$imageNamepath = $request->image->move(public_path('images'), $imageName);
/*Image Upload*/
$input = $request->all();
$input['image'] = $imageName;
$coil = Coils::create($input);
Session::flash('success', 'New coil added successfully.');
return redirect('/unit-list');
}

Google Map Filter Api Example

Here is Google Map Filter Api Example: