Skip to content

Instantly share code, notes, and snippets.

View ioniacob's full-sized avatar
🐌
Exploring the code is like life itself.

Ion Iacob ioniacob

🐌
Exploring the code is like life itself.
View GitHub Profile
@ioniacob
ioniacob / woocommerce_thankyou_order_received_text
Created May 22, 2022 09:05
Cambiar el texto de la página de gracias La página por defecto tiene un texto bajo el título, podemos cambiarlo usando el Hook woocommerce_thankyou_order_received_text, con el siguiente código cambiamos ese texto y además agregamos el nombre del usuario.
Gracias a https://decodecms.com/personalizar-pagina-de-gracias-de-woocommerce/#Cambiar_el_texto_de_la_p%C3%A1gina_de_gracias
Cambiar el título de la página de gracias
WooCommerce tiene un Hook dinámico para las páginas principales de la tienda que crea el plugin, en este caso nos interesa la página de gracias, por lo tanto el hook a utilizar es woocommerce_endpoint_order-received_title.
En el siguiente ejemplo cambiamos el título de la página y además agregamos el nombre del usuario.
add_filter( 'woocommerce_endpoint_order-received_title', 'dcms_thank_you_title');
function dcms_thank_you_title(){
$current_user = wp_get_current_user();
$first_name = esc_html( $current_user->user_firstname );
@ioniacob
ioniacob / functions.php
Last active May 21, 2022 19:08 — forked from orfeomorello/functions.php
Customize Wordpress Profile
function remove_personal_options(){
echo '<script type="text/javascript">jQuery(document).ready(function($) {
$(\'form#your-profile > h2:first\').remove(); // remove the "Personal Options" title
$(\'form#your-profile tr.user-rich-editing-wrap\').remove(); // remove the "Visual Editor" field
$(\'form#your-profile tr.user-syntax-highlighting-wrap\').remove(); // remove the "resaltado de sintaxis al editar código" field
$(\'form#your-profile tr.user-admin-color-wrap\').remove(); // remove the "Admin Color Scheme" field
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Simple Backbone WordPress Example</title>
<link rel="stylesheet" href="base.css">
</head>
<body>
<ul id="post-list"></ul>
@ioniacob
ioniacob / ViewController.swift
Created February 7, 2018 00:16 — forked from nicktesla2011/ViewController.swift
WKWebView View Controller for Xcode 9.0/Swift 4/iOS11
//
// ViewController.swift
// Honk
//
// Created by Nick Gressle on 9/23/17.
// Copyright © 2017 nick gressle illustrations llc. All rights reserved.
//
import UIKit
import WebKit
@ioniacob
ioniacob / woocommerce-optimize-scripts.php
Created February 4, 2018 21:28 — forked from DevinWalker/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@ioniacob
ioniacob / gist:c7dd4254292c18506aee05704419d6d8
Created November 11, 2016 23:45 — forked from corsonr/gist:7839908
Automatically add product to cart on visit - WooCommerce
/*
* Add item to cart on visit
*/
function add_product_to_cart() {
if ( ! is_admin() ) {
global $woocommerce;
$product_id = 64;
$found = false;
//check if product already in cart
if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
@ioniacob
ioniacob / gist:9d767cff4553767948d15cfda9da6189
Created October 22, 2016 15:04 — forked from growdev/gist:4074021
WooCommerce - Remove the "Related Products" section from a template by removing the related posts query arguments.
<?php
/*
* wc_remove_related_products
*
* Clear the query arguments for related products so none show.
* Add this code to your theme functions.php file.
*/
function wc_remove_related_products( $args ) {
return array();
}
@ioniacob
ioniacob / custom-my-account-endpoint.php
Created October 20, 2016 00:27 — forked from claudiosanches/custom-my-account-endpoint.php
Example of custom My Account endpoint.
<?php
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
@ioniacob
ioniacob / functions.php
Created October 18, 2016 13:31 — forked from kloon/functions.php
WooCommerce 2.1 Add confirm password field on My Account register form
<?php
// Add the code below to your theme's functions.php file to add a confirm password field on the register form under My Accounts.
add_filter('woocommerce_registration_errors', 'registration_errors_validation', 10,3);
function registration_errors_validation($reg_errors, $sanitized_user_login, $user_email) {
global $woocommerce;
extract( $_POST );
if ( strcmp( $password, $password2 ) !== 0 ) {
return new WP_Error( 'registration-error', __( 'Passwords do not match.', 'woocommerce' ) );
}
@ioniacob
ioniacob / gist:e1d558fc8308849dc3defe47cbb653fb
Created October 18, 2016 13:29 — forked from kloon/gist:2376300
WooCommerce Automatically add product to cart on site visit
/*
* goes in theme functions.php or a custom plugin
**/
// add item to cart on visit
add_action( 'template_redirect', 'add_product_to_cart' );
function add_product_to_cart() {
if ( ! is_admin() ) {
$product_id = 64;
$found = false;
//check if product already in cart