WP_LIST_TABLE - complete code for searching, listing, pagination:
1. First register a menu to maintain a view:
2. Now maintain list callback function:
3. List table class file code:
.:Happy coding:.
WP_LIST_TABLE - complete code for searching, listing, pagination:
1. First register a menu to maintain a view:
2. Now maintain list callback function:
3. List table class file code:
.:Happy coding:.
Hide calculate shipping for a specific product in woocommerce:
Write the following code in your functions.php:
.:Happy coding:.
1. Stop Laragon.
2. Remove all files and folders from mysql-8 in laragon -> data -> mysql-8.
3. Open terminal and go to this directory: laragon -> bin -> mysql -> mysql-8 -> bin
4. Run this command: mysqld --initialize --console
5. Run this command: start mysqld
6. Enter in to mysql: mysql -u root -p
7. Password has given in step 42
8. Run this command: ALTER USER 'root'@'localhost' IDENTIFIED BY '';
9. Close mysqld window and start laragon.
Enjoy mysql 8 in laragon!
Mysql import from a SQL file by command line way:
Open command line and login to your mysql database by typing below command:
mysql -u root -p password then press enter.
mysql > source path_of_your_sql_file.sql Eg: if your file in D drive then path will be D:\mysql.sql
Then press enter all your tables will be imported soon.
When gitignore is not working for already committed files or folders.
In that time you need to run the below comment first:
git rm --cached file_name
Or
git rm --cached folder_name
Or
git rm --cached -r folder_name
It will clear committed stuff from git.
Then you can commit and push your branch.
Set local timezone in wordpress programatically:
Happy coding!
Get completed orders count for a specific user with a specific product in Woocommerce:
Code:
Happy coding...
Laravel - raw query with pagination:
class InventoryController extends Controller
{
public function index(Request $request)
{
$sql = "SELECT *,products.name as product_name, product_categories.name as category_name, products.id as productid,
( SELECT SUM(buy_products.qty) as purcahse_qty
FROM buy_products
WHERE buy_products.product_id=products.id GROUP BY buy_products.product_id ) as bqty,
( SELECT SUM(sell_products.qty) as order_qty
FROM sell_products
WHERE sell_products.product_id=products.id GROUP BY sell_products.product_id ) as sqty
FROM products LEFT JOIN product_categories ON products.product_category_id=product_categories.id
";
$results = DB::select($sql);
$productInventoryData = $this->arrayPaginator($results, $request);
return view('auth.inventory.inventory_list')->with('productInventoryData', $productInventoryData);
}
public function arrayPaginator($array, $request)
{
$page = is_null($request->get('page')) ? 1 : $request->get('page');
$perPage = 2;
$offset = ($page * $perPage) - $perPage;
return new LengthAwarePaginator(array_slice($array, $offset, $perPage, true), count($array), $perPage, $page,
['path' => $request->url(), 'query' => $request->query()]);
}
}
And in views you can use links as like DB query build we use.
Thanks and happy coding.
In Finnish, the imperfekti is the past tense that describes actions that happened in the past, like the English simple past (e.g., "I ...