Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
@dexit
dexit / functions.php
Created December 16, 2024 16:31 — forked from yousufansa/functions.php
WooCommerce - Adding <span> wrap on order item variation name
if ( ! function_exists( 'around_wc_order_item_name' ) ) {
function around_wc_order_item_name( $name, $item ){
$variation_id = $item['variation_id'];
if( $variation_id > 0 ) {
$product_id = $item['product_id'];
$_product = wc_get_product( $product_id );
$product_name = $_product->get_title();
$_name = $product_name;
$variation_name = str_replace( $product_name . ' -', '', $item->get_name() );
$_name .= '<span class="your-class">' . $variation_name . '</span>';
@dexit
dexit / gist:7dce5d51a374f1e3bbed6efc8bf70d62
Created December 16, 2024 16:28 — forked from NickMkrtchyan/gist:bbd3f05d233dff84484cd09260be0475
Complate Corporate/Customer Woo Script
<?php
// Custom registration form for WooCommerce
function custom_woocommerce_register_form() {
$user_role = ( ! empty( $_POST['user_role'] ) ) ? sanitize_text_field( $_POST['user_role'] ) : '';
$company_id = ( ! empty( $_POST['company_id'] ) ) ? sanitize_text_field( $_POST['company_id'] ) : '';
?>
<p class="form-row form-row-wide">
<label for="user_role"><?php _e( 'Choose account type', 'woodmart' ); ?></label>
@dexit
dexit / woologin.php
Created December 16, 2024 16:27 — forked from neilgee/woologin.php
Add WooCommerce MyAccount Login/Logout Menu Items to Registered Menu
<?php //<~ don't add me in
add_filter( 'wp_nav_menu_items', 'my_account_loginout_link', 10, 2 );
/**
* Add WooCommerce My Account Login/Logout to Registered Menu
*
* @link https://support.woothemes.com/hc/en-us/articles/203106357-Add-Login-Logout-Links-To-The-Custom-Primary-Menu-Area
*/
function my_account_loginout_link( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'primary') { //change your theme registered menu name to suit
@dexit
dexit / functions.php
Created December 16, 2024 16:27 — forked from paaljoachim/functions.php
Tutorial: WooCommerce Checkout: Add multiple custom fields to billing area. This code adds priority placement of field. Shows the custom fields in the backend Order Details screen and in e-mails to the admin and customer. I have also adjusted the checkbox field to give a text result instead of a value of 1. Checkbox is also pre-selected.
/* --------- Adds custom fields using filters. ------
The below custom fields shows various types one can use.
It is then displayed in the backend Order Details page and in admin and customer e-mails.
Checkboxes by default result only show the number 1 when clicked. I have added code so that when the a checkbox is clicked it will
show text such as On and Yes. Checkbox is also pre-selected.
Tutorial: https://easywebdesigntutorials.com/woocommerce-modifying-the-checkout-page/
*/
// Initial inspiration: https://businessbloomer.com/woocommerce-add-shipping-phone-checkout/
// My Custom Fields
@dexit
dexit / upload-patentino-woocommerce-login-checkout-page-conditional-cateogry-product-array-json.php Conditional category product with custom field input file (patentino) into Woocommerce page login and checkout - Array JSON
<?php
/**
* File Upload @ WooCommerce My Account Registration
*/
// --------------
// 1. Add file input to register form
@dexit
dexit / upload-patentino-woocommerce-login-checkout-page.php
Created December 16, 2024 16:25 — forked from FrancoStino/upload-patentino-woocommerce-login-checkout-page.php
Custom field input file (patentino) into Woocommerce page login and checkout
<?php
/**
* File Upload @ WooCommerce My Account Registration
*/
// --------------
// 1. Add file input to register form
@dexit
dexit / add_tab_myaccount.php
Created December 16, 2024 16:25 — forked from em-piguet/add_tab_myaccount.php
WOOCOMMERCE add page in my account
<?php
/**
* Ajoute un tab/endpoints dans la partie mon compte
* https://nicola.blog/2017/08/01/add-enquiry-form-my-account-woocommerce-contact-form-7/
*
*/
class WC_Custom_My_Account_Tabs extends WC_Query {
/**
* Adds main filters and actions and inits the endpoints.
@dexit
dexit / code.php
Created December 16, 2024 16:23 — forked from samueleastdev/code.php
Easily Extend Woocommerce Account Page With Custom Menu And Template
<?php
function streamium_add_watchlist_endpoint() {
add_rewrite_endpoint( 'watchlist', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'streamium_add_watchlist_endpoint' );
<?php
/**
* Plugin Name: WooCommerce Custom Account Tabs
* Plugin URI: https://www.example.com/
* description: PHP Class to generate new account tabs for WooCommerce My Account page
* Version: 1.0
* Author:
* Author URI: https://gist.github.com/JiveDig/0d3658676127f30a098859228fc5d8eb
* License: GPL2
@dexit
dexit / register.php
Created December 16, 2024 16:23 — forked from nomanur/register.php
woocommerce custom registration field on account
<?php
/**
* Plugin Name: WooCommerce Registration Fields
* Description: My Custom registration fields.
* Version: 1.0
* Author: Antonio Crespo
* License: GPL2
*/
/* Extra Fields in WooCommerce Registration */