Create programmatically a product using CRUD methods in Woocommerce 3

You are not accessing the WC_Product_simple instance object from your custom Dropship Data Scraper plugin. The guilty can be mostly 2 things: You have not installed Woocommerce. The plugin Dropship Data Scraper is outdated and needs changes, to handle woocommerce. Try to include the global Woocommerce object and to enable Woocommerce support in your plugin. … Read more

Rails 3.1 remote requests submitting twice

Adding config.serve_static_assets = false to development.rb will prevent loading files from /public/assets. Actually I need to precompile locally because my test mode is using only static assets from /public/assets – tests are catching possible production asset problems. How? Just set config.assets.compile = false and config.serve_static_assets = true in test.rb configuration.

Bootstrap modal in React.js

I was recently looking for a nice solution to this without adding React-Bootstrap to my project (as Bootstrap 4 is about to be released). This is my solution: https://jsfiddle.net/16j1se1q/1/ let Modal = React.createClass({ componentDidMount(){ $(this.getDOMNode()).modal(‘show’); $(this.getDOMNode()).on(‘hidden.bs.modal’, this.props.handleHideModal); }, render(){ return ( <div className=”modal fade”> <div className=”modal-dialog”> <div className=”modal-content”> <div className=”modal-header”> <button type=”button” className=”close” data-dismiss=”modal” aria-label=”Close”><span … Read more

PHP and Microsoft Access database – Connection and CRUD

PDO If you want to interface with an MS Access database using PHP, PDO is available for you. <?php try { $pdo = new PDO(“odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\accounts.mdb;Uid=Admin”); } catch (PDOException $e) { echo $e->getMessage(); } When using PDO, due to the unified interface for DB operations, you have the opportunity to make your app … Read more

Single DAO & generic CRUD methods (JPA/Hibernate + Spring)

Here is an example interface: public interface GenericDao<T, PK extends Serializable> { T create(T t); T read(PK id); T update(T t); void delete(T t); } And an implementation: public class GenericDaoJpaImpl<T, PK extends Serializable> implements GenericDao<T, PK> { protected Class<T> entityClass; @PersistenceContext protected EntityManager entityManager; public GenericDaoJpaImpl() { ParameterizedType genericSuperclass = (ParameterizedType) getClass() .getGenericSuperclass(); this.entityClass … Read more

Easiest Form validation library for PHP? [closed]

I wrote a simple class of my own, combining some regexes i collected over the years with PHP’s sanatize and filter functions. <? /** * Pork Formvalidator. validates fields by regexes and can sanatize them. Uses PHP filter_var built-in functions and extra regexes * @package pork */ /** * Pork.FormValidator * Validates arrays or properties … Read more

How to perform update operations on columns of type JSONB in Postgres 9.4

If you’re able to upgrade to Postgresql 9.5, the jsonb_set command is available, as others have mentioned. In each of the following SQL statements, I’ve omitted the where clause for brevity; obviously, you’d want to add that back. Update name: UPDATE test SET data = jsonb_set(data, ‘{name}’, ‘”my-other-name”‘); Replace the tags (as oppose to adding … Read more