Skip to content

Instantly share code, notes, and snippets.

@wp126
wp126 / function.php
Created August 5, 2022 10:59
create custom post type
<?php
function create_posttype() {
register_post_type( 'movies',
// CPT Options
array(
'labels' => array(
'name' => __( 'Movies' ),
'singular_name' => __( 'Movie' )
),
@wp126
wp126 / index.py
Last active August 24, 2022 12:39
Convert Csv to Json in Python
import csv
import json
# Function to convert a CSV to JSON
# Takes the file paths as arguments
def make_json(csvFilePath, jsonFilePath):
# create a dictionary
data = {}
@wp126
wp126 / function.php
Created August 29, 2022 05:06
Create Situations in BuddyPress Email
<?php
/**
* Plugin Name: Run Action User
* Description:
* Version: 1.0
* Copyright: 2022
* Text Domain: run-action-user
* Domain Path: /languages
*/
@wp126
wp126 / function.php
Created September 2, 2022 05:40
Send forcefully email to woocommerce on status changed
add_action( 'woocommerce_order_status_split-order', 'bbloomer_status_custom_notificationa', 20, 2 );
function bbloomer_status_custom_notificationa( $order_id, $order ) {
$mailer = WC()->mailer()->get_emails();
$mailer['wc_order_status_email_107387']->trigger( $order_id );
}
@wp126
wp126 / function.php
Created September 14, 2022 08:33
update stock and price in woocommerce
<?php
$product = new WC_Product( 5 );
$product->set_price( 10 );
$product->set_stock_quantity(3 );
$product->save();
@wp126
wp126 / in cmd write
Last active September 21, 2022 07:29
Create Cron Job in Xampp
#for create
schtasks /create /tn "XamppCron" /tr "D:\xampp\php\php.exe D:\xampp\htdocs\cron.php" /sc minute /mo 1
#for delete
schtasks /delete /tn "XamppCron"
#for status check
schtasks /Query /TN "XamppCron"
@wp126
wp126 / base64tomedia.php
Last active September 21, 2022 09:22
Upload a base64 string as image to the WordPress media library
function save_image( $base64_img, $title ) {
require_once( ABSPATH . 'wp-admin/includes/image.php' );
// Upload dir.
$upload_dir = wp_upload_dir();
$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR;
$img = str_replace( 'data:image/png;base64,', '', $base64_img );
$img = str_replace( ' ', '+', $img );
$decoded = base64_decode( $img );
@wp126
wp126 / url
Created October 19, 2022 11:48
Call controller by generate url in prestashop
index.php?fc=module&module=MODULE_NAME&controller=CONTROLLER_NAME
@wp126
wp126 / Update Product Price in Preastashop
Created October 19, 2022 11:50
Update Product Price in Preastashop
$product = new Product(3);
$product->price = 30;
$product->save();
@wp126
wp126 / Update Attribute and Combination Price in Prestashop
Created October 19, 2022 11:52
Update Attribute and Combination Price in Prestashop
$combination = new Combination(20);//id_product_attribute add there
$combination->price = (float)20;
$combination->save();