Skip to content

Instantly share code, notes, and snippets.

@gitussr
gitussr / README.md
Created October 30, 2025 13:39
WooCommerce Quantity input dynamic based on actual stock levels.

I've created a clean, focused solution that makes the quantity input dynamic based on actual stock levels. What This Code Does: ✅ Dynamic Max Value

Automatically sets max attribute to current stock quantity Works for both simple and variable products

✅ Real-time Validation

Custom error messages: "Maximum quantity allowed is [stock]"

Updated code with complete cart validation that prevents users from adding more than available stock. New Features Added: 🛡️ Stock Validation (Core Protection)

Add to Cart Prevention - Blocks adding items if it would exceed available stock Cart Update Prevention - Stops users from increasing quantity beyond stock in cart Maximum Quantity Enforcement - Sets max attribute on quantity input fields Real-time Stock Display - Shows "(X available)" next to quantity selector

✅ WPClever Quick View Support

@gitussr
gitussr / README.md
Created October 30, 2025 11:09
WooCommerce Product Stock, Thresold, Attributes

Features:

Simple Products: Displays stock quantity, threshold, and status (In Stock/Low Stock/Out of Stock) Variable Products:

Shows total stock across all variations Lists each variation with its individual stock and threshold Highlights variations with low stock or out of stock status

@gitussr
gitussr / index.php
Created September 25, 2025 05:37
Youtube Video Playlist Fetch
<?php
// You can replace this static HTML with a dynamic loop to fetch and display YouTube videos
// For example, using YouTube API to get latest videos from a channel
$api_key = 'API_KEY';
$channel_id = 'CHANNEL_ID';
$max_results = 5;
$response = wp_remote_get("https://www.googleapis.com/youtube/v3/search?key={$api_key}&channelId={$channel_id}&maxResults={$max_results}&part=snippet");
if (is_array($response) && !is_wp_error($response)) {
$videos = json_decode($response['body'], true);
@gitussr
gitussr / db.js
Created December 13, 2024 10:47
Node JS with MongoDB
const { MongoClient } = require('mongodb');
const url = "mongodb://localhost:27017/";
// Connect to MongoDB
MongoClient.connect(url, { useUnifiedTopology: true }, async (err, client) => {
if (err) throw err;
try {
// Get the database
const dbo = client.db("mydb");
@gitussr
gitussr / readme.md
Last active June 28, 2024 05:35
Photo upload using PHP and MySQL

1. Database Connection (connect.php):

<?php

$db_host = "localhost";
$db_user = "your_username";
$db_password = "your_password";
$db_name = "your_database_name";

// Create connection
@gitussr
gitussr / readme.md
Last active June 10, 2024 11:07
Login System PHP and MySQL(Procedural)

Database Setup (users table):

CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(50) NOT NULL UNIQUE,
  email VARCHAR(100) NOT NULL UNIQUE,
  password VARCHAR(255) NOT NULL,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
@gitussr
gitussr / functions.php
Created May 15, 2024 05:37
WordPress Functions File
<?php
/**
* Enqueue Theme Assets
* */
function freightsave_assets() {
//Bootstrap Core CSS
wp_enqueue_style( 'bootstrap', 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css', '', '5.3.3', 'all' );
wp_enqueue_style( 'bootstrap-icon', 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css', '', '1.11.3', 'all' );
@gitussr
gitussr / index.php
Created May 8, 2024 08:35
Blogpost Form Validation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Create Blog Post</title>
</head>
<body>
<h1>Create Blog Post</h1>
<?php if (isset($_SESSION['errors'])): ?>
<div class="error">
@gitussr
gitussr / index.php
Created May 8, 2024 08:26
PHP Form validation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Secure Form</title>
</head>
<body>
<h1>Registration Form</h1>
<form action="process.php" method="post">
<label for="name">Name:</label>